473,246 Members | 1,495 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,246 software developers and data experts.

DataGrid Question

C# .NET 1.1

I have a datagrid bound to a dataset.
this.dgMyData.SetDataBinding(this._dataSet, "SomeData");

After I select multiple rows how do I access the data from the selected
rows?

Thank You
Peter
Feb 8 '06 #1
3 1728
Hi Peter,

To get a single row that is selected, please use the CurrencyManager like:

CurrencyManager cm =
(CurrencyManager)this.dbMyData.BindingContext[this._dataSet, "SomeData"];

cm.Current is the selected row.

If you need to get all the seleted rows, you have to go through all the
rows on the grid and use IsSelected method to check if that row is
selected. Here is an example:

for(int i=0;i<this.dataGrid1.VisibleRowCount;i++)
{
if(this.dataGrid1.IsSelected(i))
MessageBox.Show("Row "+i.ToString());
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Feb 8 '06 #2

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:DO***************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

To get a single row that is selected, please use the CurrencyManager like:

CurrencyManager cm =
(CurrencyManager)this.dbMyData.BindingContext[this._dataSet, "SomeData"];

cm.Current is the selected row.

If you need to get all the seleted rows, you have to go through all the
rows on the grid and use IsSelected method to check if that row is
selected. Here is an example:

for(int i=0;i<this.dataGrid1.VisibleRowCount;i++)
{
if(this.dataGrid1.IsSelected(i))
MessageBox.Show("Row "+i.ToString());
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


That's what I needed

Thank You
Feb 8 '06 #3
You're welcome!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Feb 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: magister | last post by:
Hello, I have xml like this.... <test> <question>sdfsa</question> <section><question>43ga</question> <question>asdf</question> </test>
0
by: Randy | last post by:
Hello, I have two questions... I have a datagrid. I'm capturing the cell via HitTestInfo. The first question is fairly simple. I'm using an example of how to capture the row/column I found on the...
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...
6
by: BBFrost | last post by:
I'm using Net 1.1 (2003) SP1 & Windows 2000 Here's the issue ... Rows 12 thru 24 are selected in a datagrid. The user now unselects rows 12 thru 24 and selects rows 45 thru 70 ??? How can...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
2
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
3
by: Danky | last post by:
Hello Masters! Anyone can help me with the datagrid, well, the app load a lot of data from DB and it show on the datagrid, and well, I need to allow paging and.... the issue is with the event...
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.