Firstly, you may have already know you can make cell, row or column of
DataGridView select-able. In your case, make sure the DataGridView's
SelectionMode is set to RowHeaderSelect, or FullRowSelect.
Then, you can handle SelectionChanged event:
private void DataGridView1_SelectionChanged(...)
{
if (DataGridView1.SelectedRows.Count==0) return;
//Do something with the SelectedRows, it could be one row, or multiple
rows. For example:
Label1.Text=DataGridView1.SelectedRows[0].Cells[0].Value.ToString();
...
}
[quoted text, click to view] "thewanz" <thewanz@discussions.microsoft.com> wrote in message
news:B2A0B9C0-3A63-4945-BA0C-706A5D27CE5A@microsoft.com...
> Hello,
> I would like to take the values contained in columns of a selected row and
> display them in textboxes for editing. When I dbl click the datagridview
> control it creates an event handler for the selected cell. Isn't there a
> specific event handler for a selected row?
>
> Wnz
Excellent! This works, thanks for the tip on the selection mode, too!
Cheers,
Wnz
[quoted text, click to view] "Norman Yuan" wrote:
> Firstly, you may have already know you can make cell, row or column of
> DataGridView select-able. In your case, make sure the DataGridView's
> SelectionMode is set to RowHeaderSelect, or FullRowSelect.
>
> Then, you can handle SelectionChanged event:
>
> private void DataGridView1_SelectionChanged(...)
> {
> if (DataGridView1.SelectedRows.Count==0) return;
>
> //Do something with the SelectedRows, it could be one row, or multiple
> rows. For example:
>
> Label1.Text=DataGridView1.SelectedRows[0].Cells[0].Value.ToString();
> ...
> }
>
> "thewanz" <thewanz@discussions.microsoft.com> wrote in message
> news:B2A0B9C0-3A63-4945-BA0C-706A5D27CE5A@microsoft.com...
> > Hello,
> > I would like to take the values contained in columns of a selected row and
> > display them in textboxes for editing. When I dbl click the datagridview
> > control it creates an event handler for the selected cell. Isn't there a
> > specific event handler for a selected row?
> >
> > Wnz
>
Don't see what you're looking for? Try a search.