I have a question regarding the Datagridview control. When I use mouse to select one cell, the value of this cell will be selected automatically, but I would prefer it not being selected, just put the cursor at the end of the value. How can i do that
Thanks

Datagridview cell content deselect
Anudeep_Chappa_2dc7df
Marcos Dell Antonio de Souza
progames25
It worked perfecctly here. Do you have the Heedselect logic every where.
Did you try that in a new project Also did you set the properties like Multiselect
robhare
I didn't set any of those. Whatever I set is set in code. Try unsetting the things you set, like edit on enter etc and then see if the de-select works>
Btw it's "code" it's never "codes".
cheston
xxfredxx
Thanks for the reply. I tried your code, but somehow it is not working as expected. The content in the cell is still selected when clicking the cell, and the assignment of "false" is always not successfully executed. Not sure why.
DGV1.SelectedCells(0).Selected = False
cooldoger
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private HeedSelect As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
con.Open()
DGV1.MultiSelect = False
DGV1.DataSource = adodb.GetTable("Categories")
HeedSelect = True
End Sub
Private Sub DGV1_SelectionChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles DGV1.SelectionChanged
If Not HeedSelect Then Exit Sub
If DGV1.SelectedCells.Count <> 0 Then
DGV1.SelectedCells(0).Selected = False
End If
End Sub
End Class
Mark Rendle
OK. It was the EditonEntry property setting.
NEVER change control properties and then tell a developer their code doesn't work. Normally, I include all properties settings in my code like I did with Multiselect.
Of course select is going to be on with the EditonEntry. EditOnEntry reselects on entry.
This question is answered and I recognize that there is more information that you need but this question has been answered.
I think to get the effect you want, you have to use the cellbeginedit and cellendedit. I also don't think you will like the effect you want. Microsoft control in XP, keep the item selected when editing.