Display grid on demand on demand
We are using the Infragistics grid (we will most likely have version 8.2 at the end) and we want to customize the appearance of rows / cells "on demand" to be able to provide a kind of "dynamic appearance".
For example, I want some cell to be red or green, depending on its value. We may want to change other characteristics (font, size, image, etc.).
The ideal place for this is some kind of event that happens before the cell repaints ... But it looks like there is no such event in Infragistics ...
Or I'm wrong? Any help?
Clarification: I'm talking about WinForms Infragistics UltraGrid
source to share
I had to do just that with IG WebGrid a few years ago, and it was ... we'll talk ... painful. However, WebGrid had the advantage of one render point - after the HTML was released, we were set!
To deal with this in WinGrid, I tried various events, both on the grid and at the data source, and met with extreme failure at every turn. The only event I got was Paint
that it will probably create a performance issue.
For Paint
, here's what I hacked together. I'm not proud of this code and I probably won't be releasing it, but here it is anyway (C #):
private void UltraGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
foreach (UltraGridRow r in UltraGrid1.Rows)
{
foreach (UltraGridCell c in r.Cells)
{
if (c.Text == "foo")
c.Appearance.BackColor = Color.Green;
}
}
}
and VB:
Private Sub UltraGrid1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles UltraGrid1.Paint
For Each r As UltraGridRow In UltraGrid1.Rows
For Each c As UltraGridCell In r.Cells
If c.Text = "foo" Then
c.Appearance.BackColor = Color.Green
End If
Next
Next
End Sub
source to share
There is an event. I don't remember exactly what he named, but it should be something like "DataRowBound" or "ItemDataBinding" etc.
Also, this article can help.
Not that it has anything to do with your question, but I would stay away from heavy use of Infragistics controls - they are very heavy and will slow down the page rendering process significantly. Only my $ 0.02.
source to share