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

How to specify a gradient or other brush for the GroupBarItem background in WinForms GroupBar?

Platform: WinForms |
Control: GroupBar |
Published Date: April 30, 2011 |
Last Revised Date: January 2, 2020

GroupBarItem background

The GroupBar control permits programmatic assignment of any System.Drawing.Brush derived class for drawing the GroupBarItem background region through the GroupBarItem.BackgroundBrush property.

The following code excerpt demonstrates creating and assigning a GradientBrush for one of the GroupBarItem objects.

C#

// Set up the Blend for the GradientBrush
Blend blend = new Blend();
blend.Factors = new float[] {0.0f, 0.0f, 1.0f};
blend.Positions = new float[] {0.0F, 0.5f, 1.0F};
// Estimate the GroupBarItem bounds
Rectangle rcgroupbaritem = new Rectangle(0, 0, this.groupBar1.Width, this.groupBar1.GroupBarItemHeight);
// Create and initialize the LinearGradientBrush
LinearGradientBrush lgbrush = new LinearGradientBrush(rcgroupbaritem, Color.White, Color.Red, 0, true);
lgbrush.Blend = blend;
// Assign the gradientbrush to the GroupBarItem1 of GroupBar1
this.groupBarItem1.BackgroundBrush = lgbrush;

 

VB

' Set up the Blend for the GradientBrush
blend As Blend = New Blend()
blend.Factors = New Single() {0.0f, 0.0f, 1.0f}
blend.Positions = New Single() {0.0F, 0.5f, 1.0F}
' Estimate the GroupBarItem bounds
rcgroupbaritem As Rectangle = New Rectangle(0, 0, Me.groupBar1.Width, Me.groupBar1.GroupBarItemHeight)
' Create and initialize the LinearGradientBrush
lgbrush As LinearGradientBrush = New LinearGradientBrush(rcgroupbaritem, Color.White, Color.Red, 0, True)
lgbrush.Blend = blend
' Assign the gradientbrush to the GroupBarItem1 of GroupBar1
Me.groupBarItem1.BackgroundBrush = lgbrush

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon