Datagrid row column(s) value(s) in C#

  • Thread starter Thread starter RajS
  • Start date Start date
R

RajS

Hi All,

I am new to C#. I was trying to get column values from a datagrid row( user
selected a row ) and show them in a messagebox.
How can I do that?.

Thanks for helping me.
-RajS
 
First:
private CurrencyManager cm1;
..
..
..
Second: (Load event o constructor)
cm1 = (CurrencyManager) BindingContext[dataSet,"tableName"];
// this is the dataSet binding to the DataGrid
..
..
..
third: (some where at your particular event)
string menVar = (string)dataSet.tableName.Rows[cm1.Position]["fieldName"];
// now menVar have the value you want
MessageBox.Show(menVar );

Hope this help

MajorTom

PD: the CurrencyManager is the key object for know the actual position of
the rows of your dataset
 

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