How to get selected value from DataGrid ?

  • Thread starter Thread starter William Ryan
  • Start date Start date
W

William Ryan

DataGrid.CurrentRow will give you the Row Index and the Column INdex
 
hey guyz,

i got an answer. Just want to share with you..

DataGrid1(DataGrid1.CurrentRowIndex, 0)


Note that this does not work if the grid has been sorted. Instead use
the CurrencyManager.

=======================================================
//dgCusomters is the DataGrid
CurrencyManager cm;
cm = (CurrencyManager)dgCustomers.BindingContext[
dgCustomers.DataSource, dgCustomers.DataMember];
DataRow dr = ((DataRowView)cm.Current).Row;
=======================================================

'dr' now refers to the actual DataRow from the bound DataTable that is
currently selected in the grid.

--
Michael Lang, MCSD
See my .NET open source projects
http://sourceforge.net/projects/colcodegen (simple code generator)
http://sourceforge.net/projects/dbobjecter (database app code generator)
http://sourceforge.net/projects/genadonet ("generic" ADO.NET)
 
Hi,

I filled up DataGrid using dataset. I've two Columns CountryCode,
CountryName.

When the user double clicks on the grid, I need to show the selected row
values.

example: AU - Australia.

Can anyone give me simple example.

Thanks
 
hey guyz,

i got an answer. Just want to share with you..

DataGrid1(DataGrid1.CurrentRowIndex, 0)

Regards
ItsMe :)
 

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

Back
Top