How can I get the data in a given Datagrid row or cell ?

S

Steph.

Hi,

I would like to get the Data of a given cell in the datagrid something like :

MyStringVar = MyDataGrid.TableStyles[0].Cell[X,Y].ToString();

But I can't find any way to read the data of a given cell, or row.....

Any Idea ?

Thanks for help,

Steph.

______________________________________________________________

Stephane Orban
IT Manager
EOLE-UNICLAM
EMail : (e-mail address removed)
Web : www.uniclam.com
Tel : +32 (0) 2 227 54 98
Fax : +32(0) 2 218 74 60
 
?

=?iso-8859-1?Q?Angel_J._Hern=E1ndez?=

Hi there...

You could use the CurrencyManager Class as shown below (asigning value to label1.Text) or
using datagrid's CurrentCell property (label2.Text).


private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) {
CurrencyManager cm = (CurrencyManager) dataGrid1.BindingContext[dataSet11.Tables[0]];
label1.Text = cm.Position > -1 ? ((DataRowView) cm.Current).Row[dataGrid1.CurrentCell.ColumnNumber].ToString() :
string.Empty;

label2.Text = dataSet11.Tables[0].Rows[dataGrid1.CurrentCell.RowNumber]
[dataGrid1.CurrentCell.ColumnNumber].ToString();

}

Regards,


--
Angel J. Hernández M.
MCSD




"Steph." <[email protected]> escribió en el mensaje
Hi,

I would like to get the Data of a given cell in the datagrid something like :

MyStringVar = MyDataGrid.TableStyles[0].Cell[X,Y].ToString();

But I can't find any way to read the data of a given cell, or row.....

Any Idea ?

Thanks for help,

Steph.

______________________________________________________________

Stephane Orban
IT Manager
EOLE-UNICLAM
EMail : (e-mail address removed)
Web : www.uniclam.com
Tel : +32 (0) 2 227 54 98
Fax : +32(0) 2 218 74 60
 
M

Morten Wennevik

Hi Steph,

string var = MyDataGrid[row, column].ToString();
string var = MyDataGrid[MyDataGridCell].ToString();
 

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