blah blah blah is here! blah blah » Close

up0down
link

Hey Guys!
I wish to embed an image of one central board, and 4 smaller boards connected to the central one. Then i wish to control this image, i.e. when i select "board 1" using a checkbox, i want that board to get highlighted, indicating that particular board has been selected.
Is it possible to do such fancy stuff with Visual C#? If so, then how can i do this?
Thanks
Muhu

last answered 2 years ago

1 answers

up0down
link

Well, first of all, if you only want one board to be highlighted at a time, then I'd use RadioButtons rather than CheckBoxes as it's only possible for one RadioButton in a group to be checked at any one time.
You could use PictureBoxes to load the images of the boards. For example, in Form_Load:
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImaage;
pictureBox1.Image = Image.FromFile("board1.jpg");
// and so on for the other boards
You can't really highlight a PictureBox (unless you load a diferent version of the image) though one thing you could do would be to change the borderstyle from FixedSingle (or None) to Fixed3D.
On that basis you'd need to handle the CheckedChange event for each RadioButton as follows:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
pictureBox1.BorderStyle = BorderStyle.Fixed3D;
}
else
{
pictureBox1.BorderStyle = BorderStyle.FixedSingle;
}
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
pictureBox2.BorderStyle = BorderStyle.Fixed3D;
}
else
{
pictureBox2.BorderStyle = BorderStyle.FixedSingle;
}
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
if (radioButton3.Checked)
{
pictureBox3.BorderStyle = BorderStyle.Fixed3D;
}
else
{
pictureBox3.BorderStyle = BorderStyle.FixedSingle;
}
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
if (radioButton4.Checked)
{
pictureBox4.BorderStyle = BorderStyle.Fixed3D;
}
else
{
pictureBox4.BorderStyle = BorderStyle.FixedSingle;
}
}
private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
if (radioButton5.Checked)
{
pictureBox5.BorderStyle = BorderStyle.Fixed3D;
}
else
{
pictureBox5.BorderStyle = BorderStyle.FixedSingle;
}
}

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback