DataGrid behavior

J

James Lennon

I have a WindowsForms.DataGrid that I am using to display
a datatable. The datagrid is composed of
TextBoxColumns. I would like to make the DataGrid have
the following behavior. When a user selects a row in the
datagrid that row is highlighted and selected regardless
of the column. I have accomplished this by overriding
the datagrids mouse down event and selecting the row.
However under some circumstances the text box control
gains focus and the row is no longer highlighted. How
can I stop the text box in a text box column from gaining
focus? I have tried seting focus to the control in the
mouse down handler but that did not work.

James
 
S

Steve Alpert

James said:
I have a WindowsForms.DataGrid that I am using to display
a datatable. The datagrid is composed of
TextBoxColumns. I would like to make the DataGrid have
the following behavior. When a user selects a row in the
datagrid that row is highlighted and selected regardless
of the column. I have accomplished this by overriding
the datagrids mouse down event and selecting the row.
However under some circumstances the text box control
gains focus and the row is no longer highlighted. How
can I stop the text box in a text box column from gaining
focus? I have tried seting focus to the control in the
mouse down handler but that did not work.

If your grid is REALLY read-only, on the first mouse down, remove all
controls from the datagrid controls collection with the exception of the
horizontal and vertical scroll bars...

/steveA
 
G

Guest

I tried that and it did not work. The user was still
able to select a box in the DataGrid and have the cell
change colors.

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top