If you are trying the in formload, you also may have to set this.grid.ForceCurrentCellMoveTo = true;
PBPhilip BishopApril 6, 2004 10:03 AM UTC
I have a question similar to this. I have attached a sample where the user clicks a button where it ends the edit of the cell. Then if the user clicks another cell, the first cell they selected stays highlighted. It has to do with the celldrawn even that u had us add to let the cell stay selected when a user clicks a button and thats fine. I want to know how to make it so when the user clicks another cell that the first cell becomes unselected.
AdministratorApril 6, 2004 11:13 AM UTC
One way you can do it is to refresh the old cell after drawing the rectangle over the new cell.
Private oldRow As Integer = -1
Private oldCol As Integer = -1
Private Sub Grid1_CellDrawn(ByVal sender As Object, ByVal e As GridDrawCellEventArgs) Handles Grid1.CellDrawn
Dim cc As GridCurrentCell = Me.Grid1.CurrentCell
If e.ColIndex = cc.ColIndex AndAlso e.RowIndex = cc.RowIndex AndAlso Not Me.Grid1.PrintingMode Then
Dim brush As New SolidBrush(Me.Grid1.AlphaBlendSelectionColor)
If oldRow > -1 And oldCol > -1 And (oldRow <> e.RowIndex Or oldCol <> e.ColIndex) Then
oldRow = e.RowIndex
oldCol = e.ColIndex
PBPhilip BishopApril 6, 2004 11:36 AM UTC
Once again thanx for the prompt response but arent you suppose to be on vacation?? Anyway that works but what does the -1 do on those 2 variables you set up??