Hi Jarrod,
Like the name suggests the DrawBackground event is used to paint the background of the Bar. But the XPMenus framework internally uses the CommandBars framework, and this factor has to be considered as well. The painting routines of the associated CommandBarExt and its BarControl occur after the Bar''s painting routine resulting in overwriting of the Bar''s custom painting. Hence the custom painting should be performed in the CommandBarExt.BarControl''s Paint event handler as well as shown in the code below :
this.bar1.DrawBackground += new PaintEventHandler(bar1_DrawBackground);
cmdbarext = this.mainFrameBarManager1.GetBarControl(this.bar1) as CommandBarExt;
cmdbarext.BarControl.Paint += new PaintEventHandler(BarControl_Paint);
private void bar1_DrawBackground(object sender, PaintEventArgs args)
{
// The CommandBarExt.BarControl''s painting takes place after the CommandBarExt is painted
// Hence the custom painting should be done in the CommandBarExt.BarControl''s painting routine as well
LinearGradientBrush brush = new LinearGradientBrush(cmdbarext.Bounds, Color.Yellow, Color.Red, 60, true);
args.Graphics.FillRectangle(brush, cmdbarext.Bounds.X, cmdbarext.Bounds.Y, cmdbarext.Width, cmdbarext.Height);
}
private void BarControl_Paint (object sender, PaintEventArgs e)
{
LinearGradientBrush brush = new LinearGradientBrush(cmdbarext.Bounds, Color.Yellow, Color.Red, 60, true);
e.Graphics.FillRectangle(brush, cmdbarext.Bounds.X, cmdbarext.Bounds.Y, cmdbarext.Width, cmdbarext.Height);
}
The
complete sample illustrating this is attached here. Please refer to it and let me know if this meets your requirements. We appreciate your interest in Syncfusion products.
Regards,
Guru Patwal
Syncfusion, Inc.