Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / March 2005

Tip: Looking for answers? Try searching our database.

Getting a dataset of selected rows in Windows Forms DataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sn - 30 Mar 2005 07:50 GMT
DataGrid control contains GetChanges() method to get a DataSet of rows that
have changed.

I would like to write a method GetSelectedRows() that returns a DataSet of
selected rows (may be multiple rows).  I tried to do this by extending the
DataGrid control and writing the following method:

public DataSet GetSelectedRows()
{
  ...
  CurrencyManager cm = (CurrencyManager)BindingContext[myGrid1.DataSource,
myGrid1.DataMember];

  DataRow dR = ((DataView)myGrid1.DataSource).Table.Rows[cm.Position];

 ...
}

I have two issues with this code:
1) Even when multiple rows are selected, only one row is returned.  How can
I get a collection of selected rows?
2) This works only if the data in the DataGrid is not sorted.  If I first
sort the table by any column and then select a row, say second one, DataRow
returned corresponds to the row that was in second position before sorting,
and not after sorting.  Thus a row that is not selected is returned.

Thanks for help in advance.

CSI
Sn - 31 Mar 2005 16:14 GMT
Actually DataGrid does not have GetChanges() method but the DataSet class
does that gives a set of changed rows.

Sorry for the confusion.

I am still looking forward to some help on this.

Thanks,

Siva

> DataGrid control contains GetChanges() method to get a DataSet of rows
> that have changed.
[quoted text clipped - 26 lines]
>
> CSI

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.