473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DataGrid selected rows

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

Thanks,
Ronen
Nov 13 '05 #1
4 35931
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Hughes | last post by:
I want to change one field of all selected rows to a provided value. Problem 1 I am using the Binding Manager Base to bind the datagrid to the appropriate dataTable as recommended by KB817247....
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
6
by: Dan | last post by:
I'd like to loop through selected datagrid rows and extract specified columns from those rows. How would I do that? Thanks... Dan
5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
3
by: BBFrost | last post by:
Ok, I know how to count the number of selected datagrid rows using the code below. What has me stumped is how to determine when the selected rows within a datagrid have been changed. The...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
1
by: steven shingler | last post by:
Hi all, I've got a datagrid. I have a function which selects certain rows in a datagrid thus: public void selectRows(string key, string columnName) { int count = 0; foreach(DataRow dr in...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
1
by: Jon | last post by:
Question: does datagrid1.isSelected(i) point to the same row as datatable.row(i).delete after datagrid sorted?? I am using datagrid1.isSelected(i) to identify datatable rows that have been...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.