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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Background color of a XPToolBar item

Thread ID:





61266 May 22,2007 06:25 PM UTC May 25,2007 01:04 PM UTC WinForms 4
Tags: Tools
Oleg Ogurok
Asked On May 22, 2007 06:25 PM UTC

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.


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

Hi Oleg,

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

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));


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

Thank you for your interest in Syncfusion products.

Murugan P.S

Oleg Ogurok
Replied On May 23, 2007 06:05 PM UTC

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?


JayaLakshmi [Syncfusion]
Replied On May 24, 2007 12:21 PM UTC

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 :


Kindly let me know if this helps.


Oleg Ogurok
Replied On May 25, 2007 01:04 PM UTC

Worked like a charm. Thank you very much.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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