469,572 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Help with DataGrid

I have a DataGrid on Form1 that displays a small amount of information about
employees.
On Form2 I want to have all the data displaying in text boxes about the
employee selected in the datagrid on form 1.
Is there a Id in the datagrid I can use to find out which user was selected
or which record was highlighted when double clicked.
Something like: John Thomas Employee Id 2637 was selected on Form1 and the
recordset on Form2 would use that Id as a variable in the recordset.

I know ASP quite well but I don't know how to do this in Windows Forms.

Thank you

ER*******@pacificdesignstudios.com
Nov 19 '05 #1
4 2059
Pacific,

Welcome to the DGS club. (Data grids suck)
A datagrid does not have the same rich set of events that other controls
have. They also do not allow for the simplest tasks unless you buy third
party DataGrid columns such as DropDown boxes and such. In windows you have
the DataGridTextColumn and the DataGridBoolColumn. Thats it. A DataGrid can
not even tel when the text value of a cell has changed.
I did something like what you propose by doing the following.
1. I keep a dataset in memory representing the original values of the
datagrid in order to know when the value has changed.
2. You will want to keep two or more values in memory so you can keep track
of where you are and where you were. This way you can validate the values of
where you were when you discover that the user has moved to another column.
3. You will also want to capture the left arrow keydown event and suppress
it when the user was on the first column. There is nothing worse to a user
than having the DataGrid reposition on the last column of the previous row
when the left arrow is pressed. The user gets completely lost!

Only by keeping careful control of the users keystrokes can you even begin
to think of syncing up with another form.

It sounds like you are just using the DataGrid to select the name of the
employee. Have you considered using a ListBox or ComboBox control for that.
You can use a monotype font (to line up columns) and simulate a chart on a
ComboBox.
"Pacific Design Studios" <ER*******@pacificdesignstudios.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a DataGrid on Form1 that displays a small amount of information about employees.
On Form2 I want to have all the data displaying in text boxes about the
employee selected in the datagrid on form 1.
Is there a Id in the datagrid I can use to find out which user was selected or which record was highlighted when double clicked.
Something like: John Thomas Employee Id 2637 was selected on Form1 and the recordset on Form2 would use that Id as a variable in the recordset.

I know ASP quite well but I don't know how to do this in Windows Forms.

Thank you

ER*******@pacificdesignstudios.com

Nov 19 '05 #2
By the way a good font to use on ComboBoxes would be "Lucida Console" It's
fairly standard for Windows and would allow you to line up your columns in
the text.

"Jerry" <Je*********@yahoo.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
Pacific,

Welcome to the DGS club. (Data grids suck)
A datagrid does not have the same rich set of events that other controls
have. They also do not allow for the simplest tasks unless you buy third
party DataGrid columns such as DropDown boxes and such. In windows you have the DataGridTextColumn and the DataGridBoolColumn. Thats it. A DataGrid can not even tel when the text value of a cell has changed.
I did something like what you propose by doing the following.
1. I keep a dataset in memory representing the original values of the
datagrid in order to know when the value has changed.
2. You will want to keep two or more values in memory so you can keep track of where you are and where you were. This way you can validate the values of where you were when you discover that the user has moved to another column. 3. You will also want to capture the left arrow keydown event and suppress
it when the user was on the first column. There is nothing worse to a user than having the DataGrid reposition on the last column of the previous row
when the left arrow is pressed. The user gets completely lost!

Only by keeping careful control of the users keystrokes can you even begin
to think of syncing up with another form.

It sounds like you are just using the DataGrid to select the name of the
employee. Have you considered using a ListBox or ComboBox control for that. You can use a monotype font (to line up columns) and simulate a chart on a
ComboBox.
"Pacific Design Studios" <ER*******@pacificdesignstudios.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a DataGrid on Form1 that displays a small amount of information

about
employees.
On Form2 I want to have all the data displaying in text boxes about the
employee selected in the datagrid on form 1.
Is there a Id in the datagrid I can use to find out which user was

selected
or which record was highlighted when double clicked.
Something like: John Thomas Employee Id 2637 was selected on Form1 and

the
recordset on Form2 would use that Id as a variable in the recordset.

I know ASP quite well but I don't know how to do this in Windows Forms.

Thank you

ER*******@pacificdesignstudios.com


Nov 19 '05 #3
Cor
The listview is much nicer for this problem
Nov 19 '05 #4
I will say one thing... Datagrids are great in ASP.NET, but the only reason
one should do it in Windows forms is to make sure your data is being filled
correctly.

Or your building a stock ticker and the only fucntionality you want is to
change colors...
"Pacific Design Studios" <ER*******@pacificdesignstudios.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a DataGrid on Form1 that displays a small amount of information about employees.
On Form2 I want to have all the data displaying in text boxes about the
employee selected in the datagrid on form 1.
Is there a Id in the datagrid I can use to find out which user was selected or which record was highlighted when double clicked.
Something like: John Thomas Employee Id 2637 was selected on Form1 and the recordset on Form2 would use that Id as a variable in the recordset.

I know ASP quite well but I don't know how to do this in Windows Forms.

Thank you

ER*******@pacificdesignstudios.com

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Michael Gorbach | last post: by
14 posts views Thread by Brett Sinclair | last post: by
2 posts views Thread by Brad Shook | last post: by
3 posts views Thread by Datatable Dataset Datagrid help | last post: by
4 posts views Thread by Jeff User | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.