469,312 Members | 2,496 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

DataGrid selected rows

How do I get the selected Rows index in the DataGrid?

Thanks,
Ronen
Nov 13 '05 #1
4 35755
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
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
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
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.

Similar topics

reply views Thread by Tom Hughes | last post: by
2 posts views Thread by Chris Plowman | last post: by
6 posts views Thread by Dan | last post: by
5 posts views Thread by Mojtaba Faridzad | last post: by
1 post views Thread by steven shingler | last post: by
1 post views Thread by Jon | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.