473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DataGrid behavior



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
Nov 15 '05 #1
2 1578
James Lennon wrote:

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
Nov 15 '05 #2
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
-----Original Message-----
James Lennon wrote:

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 allcontrols from the datagrid controls collection with the exception of thehorizontal and vertical scroll bars...

/steveA
.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MrNobody | last post by:
hey guys... I'm trying to make my DataGrid have selection behavior similar to WindowsExplorer, where I can hold CTRL to add rows to a multi-row selection. Thanks to someone else on this...
1
by: MrNobody | last post by:
Is it at all possible to override the default behavior of a DataGrid when the mouse is clicked on a row? I am having a problem where I am trying to select multiple rows in a DataGrid by...
4
by: Paul | last post by:
I sometimes get a timeout error when populating my datagrid, the code is WizardConnection.Open() UpdateCommand.CommandText = "EXECUTE sp_assign_user '" & PhysOffice.SelectedValue & "', '" &...
3
by: simchajoy2000 | last post by:
Hi, I am using a datagrid which contains a dataset with several tables and I am experiencing an inexplicable behavior that I am unable to resolve. Perhaps it's due to the complexity of my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.