By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,338 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,338 IT Pros & Developers. It's quick & easy.

DataGrid selected rows

P: n/a
How do I get the selected Rows index in the DataGrid?

Thanks,
Ronen
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

DataGrid.SelectedIndex.

from MSDN:
Remarks
Use the SelectedIndex property to determine the index of the item selected
by the user in the DataGrid control. You can also use this property to
programmatically specify which item is selected in the DataGrid control.

To deselect an item in the DataGrid control, set this property to -1.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"R Agam" <ra***@mmm.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
How do I get the selected Rows index in the DataGrid?

Thanks,
Ronen

Nov 13 '05 #2

P: n/a
Where is the SelectedIndex? can't find it.
Ronen

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi,

DataGrid.SelectedIndex.

from MSDN:
Remarks
Use the SelectedIndex property to determine the index of the item selected
by the user in the DataGrid control. You can also use this property to
programmatically specify which item is selected in the DataGrid control.

To deselect an item in the DataGrid control, set this property to -1.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"R Agam" <ra***@mmm.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
How do I get the selected Rows index in the DataGrid?

Thanks,
Ronen


Nov 13 '05 #3

P: n/a
Hi,

It;s a property of the Datagrid class :

DataGrid grid = new DataGrid()

grid.SelectedIndex = -1;

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"R Agam" <ra***@mmm.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
Where is the SelectedIndex? can't find it.
Ronen

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi,

DataGrid.SelectedIndex.

from MSDN:
Remarks
Use the SelectedIndex property to determine the index of the item selected by the user in the DataGrid control. You can also use this property to
programmatically specify which item is selected in the DataGrid control.

To deselect an item in the DataGrid control, set this property to -1.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"R Agam" <ra***@mmm.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
How do I get the selected Rows index in the DataGrid?

Thanks,
Ronen



Nov 13 '05 #4

P: n/a
To "reliably" do this (as a dg sort changes things.) You do this:
private Zone[] GetSelectedZones(DataGrid dg)
{
ArrayList al = new ArrayList();
CurrencyManager cm = (CurrencyManager)this.BindingContext[dg.DataSource,
dg.DataMember];
DataView dv = (DataView)cm.List;
for(int i = 0; i < dv.Count; ++i)
{
if(dg.IsSelected(i))
{
Console.WriteLine("Zone {0} selected.", i );
al.Add(dv[i].Row["Zone"]);
}
}
return (Zone[])al.ToArray(typeof(Zone));
}
See:
http://www.syncfusion.com/FAQ/WinForms/default.asp
"R Agam" <ra***@mmm.com> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl...
How do I get the selected Rows index in the DataGrid?

Thanks,
Ronen

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.