Help with DataGrid

  • Thread starter Thread starter Pacific Design Studios
  • Start date Start date
P

Pacific Design Studios

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

(e-mail address removed)
 
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.
 
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.
 
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...
 
Back
Top