Home › Forums › WinForms controls › Xceed Grid for WinForms › summary row and formating
-
AuthorPosts
-
#15342 |
1. how do i add summary row in a bound grid ?
2. how can i format a cell or row in a bound grid based on the value of the cell?
Imported from legacy forums. Posted by PETE (had 3995 views)
1- Simply add a summary row either in the designer or in code, and you can add it to the collection of rows you want, that is, to the fixed header rows of the grid, the footer rows of a group, the footer rows of a detail grid, etc…
e.g.:
<code>
SummaryRow summaryRow1 = new SummaryRow();
gridControl1.FixedHeaderRow.Add( summaryRow1 );
</code>.2- Use the ValueChanged event on cells, and use the sender to change the format accordingly to the value.
e.g.:
<code>
private void Form1_Load(object sender, System.EventArgs e)
{
foreach( Cell cell in dataRowTemplate1.Cells )
{
cell.ValueChanged += new EventHandler( cell_ValueChanged );
}
}void cell_ValueChanged( object sender, EventArgs e )
{
DataCell cell = sender as DataCell;
if( cell != null )
{
cell.ForeColor = Color.Red;
cell.BackColor = Color.Blue;
}
}
</code>Imported from legacy forums. Posted by André (had 339 views)
thats fine. i got the logic.
But i am having difficulties in converting this to vb.net.
Can you gime an example in vb.net plsImported from legacy forums. Posted by PETE (had 542 views)
Here is the corresponding code in VB.NET. Note however that there is bug in the present version of the grid (3.6.7204.19000) which makes this code not work. The bug is already fixed, but it will be available only in version 3.6.7213.0 and up, which will part of the next installation package to be available <a href=”http://xceed.com/pages/TopMenu/Downloads/Updates.aspx?Lang=EN-CA”>here</a>.
<code>
Dim cell As Cell
For Each cell In dataRowTemplate1.Cells
AddHandler cell.ValueChanged, AddressOf Me.Cell_ValueChanged
Next cellPrivate Sub Cell_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim cell As DataCell = CType(sender, DataCell)
If Not (cell Is Nothing) Then
cell.ForeColor = Color.Red
cell.BackColor = Color.Blue
End IfEnd Sub
</code>Imported from legacy forums. Posted by André (had 307 views)
Thorwing following exception:
An unhandled exception of type ‘System.StackOverflowException’ occurred in Xceed.Grid.dll.
Imported from legacy forums. Posted by PETE (had 535 views)
That is the exception I was referring to when saying “there is bug in the present version”. You will need to wait for the next version to be released to be able to implement this.
Imported from legacy forums. Posted by André (had 4970 views)
-
AuthorPosts
- You must be logged in to reply to this topic.