datagrid

  • Thread starter Thread starter Trond Hoiberg
  • Start date Start date
T

Trond Hoiberg

Hello. I have a datagrid in a windows form. When the user click any row i
wonder how i can retrieve the value in column 0. I was thinking that the
user should be allowed to click anywhere in the row and still the value in
the first cell is returned.
I am using VS 2005.

And while i am troubling you with this you might also know how to higlight
rows as the user moves the mouse over it?
Best regards
Trond
 
Trond said:
Hello. I have a datagrid in a windows form. When the user click any row i
wonder how i can retrieve the value in column 0. I was thinking that the
user should be allowed to click anywhere in the row and still the value in
the first cell is returned.
I am using VS 2005.

And while i am troubling you with this you might also know how to higlight
rows as the user moves the mouse over it?
Best regards
Trond

Trond,

If you are using strong typed datasets with the datagridview then you
can do something like this say if you are showing Contacts. This
assumes you want to get access to the contact's firstname, what column
it is in irrelevant.

Contact.ContactRow row =
((System.Data.DataRowView))(contactBindingSource.Current)).Row as
Contact.ContactRow;
MessageBox.Show(row.FirstName);
 
Thanks, i tried for a while and figured it out.
On datagrid click event i added: string TAG =
datagrid.CurrenRow.Cells[0].Value.ToString();

Did not solve that highlight color tho :-)
Best regards
Trond
 
Back
Top