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. Image for the cookie policy date
close icon

Covered Cell In GridDataBoundGrid

Hi All,

Is there a way to have a row that is basically a horizontal gradient with text in a GDBG? Covered ranges don't seem to exist in a bound grid.
Any help is appreciated. ~Felix


2 Replies

FD Felix De Herrera April 3, 2007 09:10 PM UTC


>Hi All,

Is there a way to have a row that is basically a horizontal gradient with text in a GDBG? Covered ranges don't seem to exist in a bound grid. Any help is appreciated. ~Felix



Figured it out:

Public Sub InsertGradientHeader(ByVal iRow As Integer, ByVal sCaption As String)
m_grid.Model.CoveredRanges.AddRange(New Syncfusion.Windows.Forms.Grid.GridRangeInfo() {Syncfusion.Windows.Forms.Grid.GridRangeInfo.Cells(iRow, 1, iRow, m_grid.Model.ColCount)})
m_grid(iRow, 1).Interior = New Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Horizontal, SystemColors.Desktop, SystemColors.Window)
m_grid(iRow, 1).Text = sCaption
m_grid(iRow, 1).Font.Bold = True
m_grid(iRow, 1).TextColor = Color.White
m_grid(iRow, 1).CellType = "Static"
m_grid(iRow, 1).ReadOnly = True
m_grid(iRow, 1).Clickable = False
m_grid(iRow, 1).Enabled = False
m_grid(iRow, 1).Text = DataInfo.CEnumsInfo.LineTypes.GradientHdr.ToString End Sub


HA haneefm Syncfusion Team April 3, 2007 10:12 PM UTC

Hi Felix,

If you want to draw the gradient text in a grid cell, you can handle the DrawCellDisplayText event and draw the gradient display text using the DrawString method. the following is the code snippet

private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex > 0 )
{
e.Cancel = true;
LinearGradientBrush myBrush = new LinearGradientBrush(e.TextRectangle, Color.Violet, Color.White, LinearGradientMode.Horizontal);
e.Graphics.DrawString(e.DisplayText,e.Style.GdipFont,myBrush,e.TextRectangle);
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon