how to prevent the user from moving to the clicked cell in DataGridView ?
-
hi The default behavior of the DataGridView is that : when the user click on a cell the focus will move to the clicked cell . I want to modify this behavior , so if the user click on a cell the focus will not move to the clicked cell how can i do that thanks
-
hi The default behavior of the DataGridView is that : when the user click on a cell the focus will move to the clicked cell . I want to modify this behavior , so if the user click on a cell the focus will not move to the clicked cell how can i do that thanks
You can make the column read only, it then won't accept the click. I think you can make the cell read only but you need to do that on the cell paint event (not sure if thats the correct event), then you can evaluate the cell content and change the properties. If you make the underlying collection (datatable of BindingSource) read only (cannot add/edit/delete) then I believe this will be reflected in the DGV. There are many ways to kill a cat other than drowning it in milk.
Never underestimate the power of human stupidity RAH
-
You can make the column read only, it then won't accept the click. I think you can make the cell read only but you need to do that on the cell paint event (not sure if thats the correct event), then you can evaluate the cell content and change the properties. If you make the underlying collection (datatable of BindingSource) read only (cannot add/edit/delete) then I believe this will be reflected in the DGV. There are many ways to kill a cat other than drowning it in milk.
Never underestimate the power of human stupidity RAH
-
hi Mycroft Holmes I don't want the value In my underlying Collection to be read only ? thanks
If you have some other control you want to keep focus on, you might just have to manually reset it.
There are three kinds of people in the world - those who can count and those who can't...
-
hi The default behavior of the DataGridView is that : when the user click on a cell the focus will move to the clicked cell . I want to modify this behavior , so if the user click on a cell the focus will not move to the clicked cell how can i do that thanks
You can disable the full datagridview as you don't want to make it readonly.
dataGridView1.Enabled = false;