I have an MSFlexGrid control with 2 columns and all of my data is displayed on this grid. When I click on the Add button, I add a new row, and I select my new row.
The problem is that all the rows get selected and I need to select only my new row.
Here's my code:
Private Sub Add_Click()
FGrid.Rows = FGrid.Rows + 1
FGrid.RowSel = FGrid.Rows - 1
FGrid.ColSel = 0
If FGrid.Rows > 1 Then ' > 10
FGrid.TopRow = FGrid.Rows - 1
Else
FGrid.TopRow = 1
End If
FGrid.TextMatrix(FGrid.RowSel, 0) = Format(Date, "DD/MM/YYYY")
FGrid.SetFocus
End Sub
Looks like you're looking for the
Rowproperty, instead ofRowSel. You can use a combination of the two though depending on your requirements.RowProperty:RowSelproperty:When you set the
RowSelvalue it's treated as the ending of the selection because theRowvalue is still 0 (unchanged). Therefore, you need to use something like this:One more thing, instead of incrementing
.Rowsand then usingTextMatrix()to assign a value to the cell, you can useAddItemto add a row with a value in its first cell. In this case, your code would look something like this: