hello there.
i am making a statement to display an image when a button is clicked, i am having an error when doning this, the error i am getting is the following:
System Drowing.Bitmap is a "type" but is used as a variable.. Please Help
System Drowing.Image is a "type" but is used as a variable.. Please Help
the code that i am using is the following:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Group_Project_final
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
panel2.Visible = true;
panel1.Visible = false;
panel3.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
panel1.Visible = true;
panel2.Visible = false;
panel3.Visible = false;
}
private void button3_Click(object sender, EventArgs e)
{
panel3.Visible = true;
panel1.Visible = false;
panel2.Visible = false;
}
private void button4_Click(object sender, EventArgs e )
{
if (button4.Text == "off")
button4.Text = "on";
//Bitmap image = new Bitmap("C:\\Users\\LionHeart\\Desktop\\PDI_individual_Project\\C#Practice\\WindowsFormsApplication2\\WindowsFormsApplication2\\Resources\\bedroom light on2.jpg");
//pictureBox1.Image = image;
else
button4.Text = "off";
if (button4.Text == "on")
Bitmap = new Bitmap("C:\\Users\\LionHeart\\Desktop\\PDI_individual_Project\\C#Practice\\WindowsFormsApplication2\\WindowsFormsApplication2\\Resources\\bedroom light on2.jpg");
pictureBox1.Image = Image;
}
}
}
if any one can help me sort that issue i will be very greatfull, thanks.
Loading
Suthish NairPosted Feb 27, 2011, 11:45 AM
Amit ChoudharyPosted Feb 23, 2011, 10:25 AM
Here is your culprit statement
if (button4.Text == "on")
Bitmap image = new Bitmap("C:\\Users\\LionHeart\\Desktop\\PDI_individual_Project\\C#Practice\\WindowsFormsApplication2\\WindowsFormsApplication2\\Resources\\bedroom light on2.jpg");
pictureBox1.Image = image;
}
added image as an object name of Bitmap class.
Note: I Suggest you note to use keyword as your local variables as i observed in your code. It'll create problem for you by giving errors now or later.
Thanks
Please mark "Do you like this answer" if it helps you.