We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

buttonAdv treat it as a checkbox - glows when it has been depressed?

Hello,

I am wondering if its possible to use the advButton and use the Office 2007 Blue theme and when the user pushes it down to retain that depressed glow. It should retain that glow until the users pushes another advButton on the form.


I was trying to do this like:

private void buttonAdv2_Click(object sender, EventArgs e)
{
buttonAdv2.State = ButtonAdvState.Checked;
buttonAdv3.State = Syncfusion.Windows.Forms.ButtonAdvState.Default;
buttonAdv3.Invalidate();
}

private void buttonAdv3_Click(object sender, EventArgs e)
{
buttonAdv3.State = ButtonAdvState.Pressed;
buttonAdv2.State = Syncfusion.Windows.Forms.ButtonAdvState.Default;
buttonAdv2.Invalidate();
}

But that doesn't work.

1 Reply

VS Vallarasu S Syncfusion Team April 21, 2010 09:33 AM UTC

Hi Dave,

You can override the OnPaint Event of the ButtonAdv Control to keep its appearance in pressed state as shown here,
ButtonAdv will be in pressed state as long as the custom added IsClicked Property is True, So update the IsClicked Property to True or False accordingly on the Buttons Click Event.

if (IsClicked)

{
Color cl1 = Syncfusion.Windows.Forms.Office2007Colors.Default.ButtonPressedTopColor;
Color cl2 = Syncfusion.Windows.Forms.Office2007Colors.Default.ButtonPressedBottomColor;
base.BackColor = Syncfusion.Windows.Forms.Office2007Colors.Default.ButtonPressedTopColor;
Rectangle rc = base.ClientRectangle;
Rectangle rcBrush = new Rectangle(rc.Left, rc.Top, 1, rc.Height);
using (LinearGradientBrush brush = new LinearGradientBrush(rcBrush,cl1,cl2, 90))
{
brush.Blend = m_blButtonPressed;
brush.WrapMode = WrapMode.TileFlipXY;
e.Graphics.FillRectangle(brush, rc);
e.Graphics.DrawString(base.Text, base.Font, Brushes.Black, base.ClientRectangle.X + 6, base.ClientRectangle.Y + 5);
}

Refer the sample in the following link which demonstrates the above,

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ButtonAdvTest1639176038.zip

Please let us know if you have any queries.

Regards
Vallarasu S.

Loader.
Live Chat Icon For mobile
Up arrow icon