Occurs whenever the grid renders a row and the FetchRowStyles property has been set.
[Visual Basic]
Public Event FetchRowStyle As FetchRowStyleEventHandler
[C#]
public event FetchRowStyleEventHandler FetchRowStyle
[Delphi]
public property FetchRowStyle: FetchRowStyleEventHandler read remove_FetchRowStyle write add_FetchRowStyle;
Remarks
Use the FetchRowStyle event to control formatting on a per-row basis, as it is much more efficient than coding the FetchCellStyle event to apply the same formatting to all columns.
Note: A common application of row-based formatting is to present rows in alternating colors to enhance their readability. Although the FetchRowStyle event could be used to achieve this effect, the AlternatingRows property is easier to use, as it requires no coding.
Example
The following code displays all rows with Germany in the Country column as LemonChiffon:
Private Sub C1TrueDBGrid1_FetchRowStyle(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles C1TrueDBGrid1.FetchRowStyle
Dim S As String = Me.C1TrueDBGrid1.Columns("Country").CellText(e.Row).ToString
If S <> "Germany" Then
e.CellStyle.BackColor = System.Drawing.Color.LemonChiffon
End If
End Sub
· C#
private void c1TrueDBGrid1_FetchRowStyle(object sender, C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs e)
{
string S = this.c1TrueDBGrid1.Columns["Country"].CellText(e.Row).ToString;
if (S != "Germany")
{
e.CellStyle.BackColor = System.Drawing.Color.LemonChiffon;
}
}
· Delphi
Procedure TForm1.C1TrueDBGrid1_FetchRowStyle(sender: objectSystem.Object; e: C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs);
var S: string;
begin
S := Self.C1TrueDBGrid1.Columns['Country'].CellText(e.Row).ToString;
if (S <> 'Germany') then
e.CellStyle.BackColor := System.Drawing.Color.LemonChiffon;
end;
See Also
C1TrueDBGrid Class | C1TrueDBGrid Members | C1.Win.C1TrueDBGrid Namespace
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |