views:

1173

answers:

3

We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and we want to configure row/cells appearances "on-demand" in order to be able to provide sort of "dynamic appearance".

For example, I want some cell to be red or green, depending on its value. We might want to tweak other characteristics as well (font, size, image, etc).

A perfect place to do it would be some event, that happen before a cell gets repainted... But it seems there is no such event in Infragistics...

Or am I wrong? Any help?

Clarification: I'm talking about WinForms Infragistics UltraGrid

A: 

There is an event. I don't remember exactly what it's called, but it's got to be something like 'DataRowBound' or 'ItemDataBinding', etc..

Also, this article might help.

Not that this has anything to do with your question, but I'd stay away from heavy use of Infragistics controls - they're very heavy and will slow down the page rendering process considerably. Just my $0.02.

Kon
upvoted to counter inconsiderate downvote
Steven A. Lowe
I appreciate the try, but the answer wan't helpful for me and it is not related to the question. So I downvoted it, that's all.
Yacoder
+1  A: 

I had to do exactly this with the IG WebGrid a few years back, and it was ... shall we say ... painful. However, the WebGrid had the advantage of a single render point -- once the HTML was emitted, we were set!

For dealing with this in WinGrid, I tried a variety of different events, both on the grid and the datasource, and met with abject failure every step of the way. The only event I got to work was Paint, which will likely create a performance issue.

For Paint, here's what I hacked together. I'm not proud of this code, and I likely wouldn't put it in production, 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
John Rudy
A: 

We have finally come up with two solutions for that problem.

For some of the dynamic content we use grid elements appearance and reinitialize it "on-demand".

For the extremely resource-critical appearance we use UltraGrid.DrawFilter (see also IUIElementDrawFilter interface).

Yacoder