So I’m creating a custom user control in .NET 2.0 and this user control is basically a combined user control ( it has a picture on it with a label ). And it’s function is basically to act like a button, it can be clicked etc.
Now the problem I have is for whatever reason the border style doesn’t support 3d borders…
So when the button is unclicked it should have the Border3dStyle.Raised look. Then when it gets pressed it should have the Border3dStyle.Sunken look.
I achieved getting the Border3dStyle.Raised by overriding the OnPaint method. Like so…
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
ControlPaint.DrawBorder3D(e.Graphics, this.ClientRectangle, Border3DStyle.Raised);
}
I have other method I’d like to call when the button itself is clicked this is what I was thinking might work.
private void UserInkControl_Paint(object sender, PaintEventArgs e)
{
Rectangle borderRectangle = this.ClientRectangle;
ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, Border3DStyle.Sunken);
}
I registered it in the load event
private void UserInkControl_Load(object sender, EventArgs e)
{
this.Paint += new System.Windows.Forms.PaintEventHandler(this.UserInkControl_Paint);
}
How can I call the UserInkControl_Paint when the click event is fired?
1 Answer