473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid behavior



I have a WindowsForms.Da taGrid 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 1591
James Lennon wrote:

I have a WindowsForms.Da taGrid 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.Da taGrid 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
1426
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 newsgroup, I found out how to detect if CTRL is pressed while in my MouseUp event, which is when it's supposed add that row to the selection. (Otherwise, if the CTRL key is not pressed I clear any current selection to start over- just like Explorer) ...
1
3380
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 left-clicking them, but each time I click another row to add it to the selection the previously added row loses it's highlighting, so it appears as though only one row is selected at any one time.
4
3923
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 & "', '" & Context.User.Identity.Name & "'" UpdateCommand.ExecuteNonQuery()
3
1245
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 scenario which I will briefly describe here just in case it is a factor: I am querying an Access database and displaying the results in a Datagrid - then the user can perform additional queries based on the displayed Access information and I then...
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.