Slydog43-2
2020-08-19T18:37:21Z
I have seen this question asked before, but never seen answer that works
How do I get cell/row highlighted with code. I see that it is lighter grey but not the same as a mouse click which turns it to the selected background color.

I use something like IGrid1.SetCurRow(0) which will select the row but its not highlighted like a mouse click would.

i tried things like

IGrid1.HighlightSelCells = True
IGrid1.CurCellBackColor = Color.Black
IGrid1.SelCellsBackColor = Color.Black
IGrid1.SelRowsBackColor = Color.Black

Thanks

abraXus
2020-08-20T01:19:03Z
I had the same question, but deleted it after I figured out what I was doing wrong.

I came to realize that it was only highlighted when it had the focus, so highlighting was not what I needed to do. Instead, i wrote some code that set the background color of the current row. Since there can be only 1 current row, and technically there can be more than one highlighted row, this made much more sense.

I came up with this and it works great. I call it on the CurRowChangeRequest event.

Private Sub tblAlternateIGrid_CurRowChangeRequest(sender As Object, e As iGCurRowChangeRequestEventArgs) Handles tblAlternateIGrid.CurRowChangeRequest
    IG_Highlight(sender, tblAlternateIGrid.CurRow.Index, e.RowIndex)
End Sub

Here is the routine that I made generic so that I could use it on any grid in my application:

Friend Sub IG_Highlight(ig As iGrid, OldIndex As Integer, NewIndex As Integer)
    If ig.Rows.Count = 0 Then Exit Sub
    For i As Integer = 0 To ig.Cols.Count - 1
        ig.Rows(OldIndex).Cells(i).ForeColor = SystemColors.ControlText
        ig.Rows(OldIndex).Cells(i).BackColor = Nothing
        ig.Rows(NewIndex).Cells(i).ForeColor = SystemColors.HighlightText
        ig.Rows(NewIndex).Cells(i).BackColor = SystemColors.Highlight
    Next
End Sub

Granted, if you are doing other things with the background color of each cell, you will need to make some adjustments, but if (like me) you are using the alternating row color feature too, this is compatible with that, since this does not change the underlying row color.
Igor/10Tec
2020-08-20T06:36:21Z
Some comments from the developer to the two posts above.

1. iGrid supports two selection modes - cell mode (the default one) and row mode. To select whole rows, activate row mode with the Boolean RowMode property. The RowSelectionInCellMode property allows you to specify how rows are selected in cell mode (no rows can be selected, one row can be selected, multiple rows can be selected). Read the section 6.2. The Row and Cell Selection topic in the manual and the related topics around it to find out more.

2. iGrid allows you to use two different color sets to highlight selected cells and selected rows, and they are differ depending whether iGrid has the input focus or not. See the iGrid color properties ending with 'NoFocus' like SelCellsBackColorNoFocus and SelRowsBackColorNoFocus.

3. If you want to use manual background color setting like in the IG_Highlight method, there is a better way to highlight all cells in a row. You can do it with the CellStyle property of the row object (iGRow) without a loop. iGRow.CellStyle returns a cell style object that affects all cells in the row, and you just need to set its BackColor property to the required value.
abraXus
2020-08-20T07:10:18Z
Glad I checked back. Igor's solution is FAR better for my needs.

        IGrid1.RowMode = True
        IGrid1.SelCellsBackColorNoFocus = IGrid1.SelCellsBackColor
        IGrid1.SelCellsForeColorNoFocus = IGrid1.SelCellsForeColor

Now to go back and update my project accordingly.

SO MANY properties... sometimes it gets hard to keep track of them all when trying to learn how to use new controls.