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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DrawBackground event in Bar class

Thread ID:

Created:

Updated:

Platform:

Replies:

18770 Sep 8,2004 08:15 PM UTC Sep 13,2004 01:20 PM UTC WinForms 2
loading
Tags: Tools
Jarrod Peace
Asked On September 8, 2004 08:15 PM UTC

Hi, What exactly is the DrawBackground event in the XPMenus.Bar class? I would think that it would allow one to override the drawing for the background of the bar, but my code doesn''t seem to be working. I have the following: private void barToolbar_DrawBackground(object sender, PaintEventArgs e) { Graphics g = e.Graphics; using (Brush b = new LinearGradientBrush(e.ClipRectangle, Color.Black,Color.White,LinearGradientMode.Horizontal)) { g.FillRectangle(b,e.ClipRectangle); } } Any idea as to what I''m doing wrong? If this is not correct, then is there some way to achieve custom drawing of the background? I''m going for a gradient background such as the one found in MS Word w/ XP themes turned on. Thanks for your help. - Jarrod

Administrator [Syncfusion]
Replied On September 10, 2004 09:53 PM UTC

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.

Jarrod Peace
Replied On September 13, 2004 01:20 PM UTC

Hi Guru, That''s perfect. Thanks a lot for your help - Jarrod

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

;