delPiero
2014-04-17T14:38:27Z
Hello,
I have an Igrid with about 20 rows and 20 columns..
I know how to change the forecolor and backcolor for each cell but is it possible to change
the color of the entire row ? this is what im using..



        If iGridSample.SelectedRows.Count > 0 Then
            For iSel As Integer = iGridSample.SelectedRows.Count - 1 To 0 Step -1
                For iCols As Integer = 0 To iGridSample.Cols.Count - 1
                    iGridSample.SelectedRows(iSel).Cells.Item(iCols).ForeColor = Color.White
                    iGridSample.SelectedRows(iSel).Cells.Item(iCols).BackColor = Color.Black
                Next
            Next
            iGridSample.PerformAction(iGActions.DeselectAllRows)
        End If
Igor/10Tec
2014-04-18T13:57:12Z
I would rewrite your code as the following:

Dim myCellStyle As New iGCellStyle
myCellStyle.ForeColor = Color.White
myCellStyle.BackColor = Color.Black

For Each loopRow As iGRow In iGridSample.SelectedRows
	loopRow.CellStyle = myCellStyle
Next

iGridSample.PerformAction(iGActions.DeselectAllRows)

Noe that there is no strong need to check whether we have selected rows. If the selected row count equals zero, the loop body won't be executed, and the PerformAction call will do nothing.

***

One more hint for code blocks like this, when you do bulk update of many cells. To speed up the process and avoid any flickering on the screen, call the BeginUpdate method before you execute this code and EndUpdate after that.