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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Background color of a XPToolBar item

Thread ID:

Created:

Updated:

Platform:

Replies:

61266 May 22,2007 02:25 PM May 25,2007 09:04 AM Windows Forms 4
loading
Tags: Tools
Oleg Ogurok
Asked On May 22, 2007 02:25 PM

Hi there,

Is there a way to set background color on a particular item inside a XPToolBar?
I have a button that I want to look different from the rest.

Thanks,
-Oleg.

Murugan [Syncfusion]
Replied On May 22, 2007 05:28 PM

Hi Oleg,

This could be achieved by handling the DrawToolbarItem event of the BarItem. Using this, we could draw background, image and String etc.

[Code]
this.barItem1.DrawToolbarItem += new DrawToolbarItemEventHandler (barItem1_DrawToolbarItem);

void barItem1_DrawToolbarItem(object sender, DrawToolbarItemEventArgs drawItemInfo)
{
Syncfusion.Windows.Forms.Tools.XPMenus.BarItem bi = (Syncfusion.Windows.Forms.Tools.XPMenus.BarItem)sender;
drawItemInfo.Graphics.FillRectangle(Brushes.Red, drawItemInfo.Bounds);
drawItemInfo.Graphics.DrawImage(bi.ImageList.Images[bi.ImageIndex],new Rectangle( drawItemInfo.Bounds.Location , new Size( drawItemInfo.Bounds.Size.Width , drawItemInfo.Bounds.Size.Height - 15 ) ) );
drawItemInfo.Graphics.DrawString(bi.Text , new Font("verdana", 7), new SolidBrush(Color.Green ), new PointF(drawItemInfo.Bounds.X, drawItemInfo.Bounds.Y + 22));
}

[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61266/Main.htm

Please refer to the sample and let me know if it helps you.

Thank you for your interest in Syncfusion products.

Regards,
Murugan P.S

Oleg Ogurok
Replied On May 23, 2007 02:05 PM

Thanks for your solution. It works. However, the hover effect is lost, e.g. when I position mouse pointer over the button, it doesn't get highlighted like the rest of the buttons.

Is there a way to preserve this effect?

-Oleg.

JayaLakshmi [Syncfusion]
Replied On May 24, 2007 08:21 AM

Hi Oleg,

Thanks for the update.

Just call a method DrawBackground()inside barItem1_DrawToolbarItem event handler to see the effect you want.

The code snippet is as follows :

drawItemInfo.DrawBackground();

Kindly let me know if this helps.

Regards,
Jaya

Oleg Ogurok
Replied On May 25, 2007 09:04 AM

Worked like a charm. Thank you very much.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;