Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Gradient or hatch background for cell/node?

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Gradient or hatch background for cell/node?
Link Posted: 13-Mar-2006 07:19
I'm inheriting Node and implementing IStyledNode so that in OnBeginPaint I can change the background color on the fly based on cell value. However, I would really like to also change the background to either gradient or support a hatchbrush. Is this possible in OnBeginPaint, seems changing CellDrawInfo.currentBrush isn't working? Thank you,
Mark
Link Posted: 13-Mar-2006 12:12
For lurkers...
Well, after playing with this most of the afternoon I found that if you set customBackgroundColor property, then it will undo any custom background you draw. So, as long as you don't set customBackgroundColor, you can create whatever kind of brush you want (LinearGradientBrush) and just call CellDrawInfo.g.FillRectangle( newbrush, info.cellRect); e.g.


Public Sub OnBeginPaint(ByVal info As CellDrawInfo) Implements IStyledNode.OnBeginPaint

Dim myBrush as Brush
Dim myGradientBrush As LinearGradientBrush = New LinearGradientBrush(info.cellRect, Color.White, Color.Blue, LinearGradientMode.ForwardDiagonal)
' The RotateTransform method rotates the brush by the user specified amount
myGradientBrush.RotateTransform(0)
' Set the point where the blending will focus.  Any single  between 0 and 1 is allowed. The default is one.
myGradientBrush.SetBlendTriangularShape(1)
myBrush = myGradientBrush
info.g.FillRectangle(myBrush, info.cellRect)