MS DataGridView question

Posted by DRidnouer on 18-Mar-2010 09:16

Hello,

I am new to GUI for .NET and I have a ABL form setup with a ProBindingSource and a MS DataGridView control.  I can get most all of the functionality I need working, but there are few issues I am still struggling with.  The main one is I cannot figure out how to mimic the ROW-DISPLAY event in a Progress browser using the DataGridView control.  I need to set the font color of certain rows based on a value of the temp-table record in those rows.  Can anyone help out?

Thanks,

Dave

All Replies

Posted by Peter Judge on 18-Mar-2010 09:54

You could subscribe to the RowStateChanged event, and look at the value of the DataGridViewRowStateChangedEventArgs Row and StateChanged properties.

-- peter

Posted by DRidnouer on 18-Mar-2010 11:23

Peter,

Thanks for your input.  I tried the 'RowStateChanged' trigger and the only time it seems to fire is when my form first starts up.  When the datasource actually is supplying data to the datagrid, the RowStateChanged does not seem to fire.  Don't know if it matters or not, but this is a non-updateable datagrid.  There is no data in it when the form starts, then the user would enter search criteria and the datasource supplies temp-table records from the DB based on the search criteria entered.

I have also tried the 'RowsAdded' event with no luck either.

Thanks,

Dave

Posted by DRidnouer on 19-Mar-2010 15:27

Ok, I am an idiot.  First off there are two DataGridView controls on the form and I put the 'RowStateChanged' trigger on the wrong one.  So it is no wonder it didn't fire.  I believe the 'RowStateChanged' would work, but I found in the OpenEdge Documentation "GUI For .NET Mapping Reference" that the .NET equivalent of Row-Display is RowPostPaint.  It helps if you read the documentation!

In case anyone is wondering here is the code used to change font color based on a value in temp-table in DataGridView-

    METHOD PRIVATE VOID dgProject_RowPostPaint( INPUT sender AS System.Object, INPUT e AS System.Windows.Forms.DataGridViewRowPostPaintEventArgs ):
        DEFINE VARIABLE oDataGridView AS DataGridView NO-UNDO.
        DEFINE VARIABLE oDataGridViewRow AS DataGridViewRow NO-UNDO.

        oDataGridView = CAST(sender,DataGridView).
        oDataGridViewRow = oDataGridView:Rows[e:RowIndex].
        IF STRING(oDataGridViewRow:Cells[0]:Value) BEGINS 'Closed' THEN DO:
                oDataGridViewRow:DefaultCellStyle:ForeColor = System.Drawing.Color:Red.            
        END.
        RETURN.

    END METHOD.

Thanks,

Dave

This thread is closed