The following class is a simple replacement for your use of the RadioButton
class from the sounds of it. As you see, it inherits the RadioButton class,
adds two extra properties (CheckedImage and UncheckedImage), as well as
overriding the OnPaint eventhandler.
To use it, simply set the before mentioned properties to those images you
want to be used and leave the rest to it, when the RadioButton is checked, it
will display the CheckedImage, when not, the UncheckedImage is drawn.
One little note about this code, the painting does scale the image to the
shape and size of the available area, if you do not want that, simply change
the call to DrawImage() to DrawImageUnscaled() with the same arguments.
I hope this does what you are looking for,
Brendan
public class PictureRadioButton : RadioButton
{
Image checkedImage;
Image uncheckedImage;
public Image CheckedImage
{
get
{
return checkedImage;
}
set
{
checkedImage = value;
}
}
public Image UncheckedImage
{
get
{
return uncheckedImage;
}
set
{
uncheckedImage = value;
}
}
public PictureRadioButton()
{
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
}
protected override void OnPaint(PaintEventArgs e)
{
Image paintingImage;
if(this.Checked)
{
paintingImage = this.checkedImage;
}
else
{
paintingImage = this.uncheckedImage;
}
e.Graphics.DrawImage(paintingImage, 0, 0, this.Width, this.Height);
}
"jo************@comcast.net" wrote:
Thank you for the quick responses. To be quite honest though, I'm a
fairly inexperienced programmer and wouldn't even know where to start
with this.