Datagrid Row

D

David Fúnez

Hi;

I have a Form with a DataGrid, i can click in a cell and that data is shown
in a textbox, but what i need is to get all the data from that row to
display it in Textboxes.

by now i just can display 1 cell, ¿how can i display the other cells from
that row?

Thanks on advance.
 
C

chris-s

Several choices..

1) add a load of controls and 'databind' them to the relevant column in
the dataset

2) use a databound control to access the 'key' value, if there is one,
and then use a separate select & datareader to retrieve the row

or

public System.Data.DataRow SelectedRow(DataGrid dataGrid)
{
if(dataGrid != null)
{
try
{
System.Windows.Forms.BindingManagerBase bm =
dataGrid.BindingContext[dataGrid.DataSource];

return ((System.Data.DataRowView) bm.Current).Row;
}
catch
{
return null;
}
}
else
return null;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top