DataRow to DataGridRow.

N

Neil Walters

Hi

Given a DataRow, is it possible to efficiently (wihtout trawling
through them all) get hold of the corresponding DataGridRow.

I have a value and want to programatically select the row in the
datagrid that contains the value. I can get hold of the DataRow by

DataRow dr = this.dataSet.Table.Rows.Find(value);

but cannot get the DataGridRow.

Thanks

Neil.
 
G

Guest

Hi,

I don't know something like DataGridRow in DataGrid control (Couldn't find it in sdk), Could you explain what functionality you want to achive in more detail.

Dincer Uyav
(e-mail address removed)
 
G

Guest

Hi,

I don't know something like DataGridRow in DataGrid control (Couldn't find it in sdk), Could you explain what functionality you want to achive in more detail.

Dincer Uyav
(e-mail address removed)
 
V

Vlado B.

Neil Walters said:
Hi

Given a DataRow, is it possible to efficiently (wihtout trawling
through them all) get hold of the corresponding DataGridRow.

I have a value and want to programatically select the row in the
datagrid that contains the value. I can get hold of the DataRow by

DataRow dr = this.dataSet.Table.Rows.Find(value);

but cannot get the DataGridRow.

Thanks

Neil.


If you want to set CurrentRowIndex to value of found DataRow you should do
the following:

CurrencyManager cm =
(CurrencyManager)this.dataGrid1.BindingContext[this.dataGrid1.DataSource,
this.dataGrid1.DataMember];
cm.Position = ((DataView)cm.List).Find(value);
or
this.dataGrid1.CurrentRowIndex = ((DataView)cm.List).Find(value);
or
this.dataGrid1.Select(((DataView)cm.List).Find(value));

but if you need DataGridRow object then AFAIK you should try with
reflection.

I hope this will help.

Vlado
 

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