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 General / December 2004

Tip: Looking for answers? Try searching our database.

how to loop through a winforms datagrid to get all selected(checke

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rekha - 07 Dec 2004 16:05 GMT
Any pointers as to how to loop through a winforms datagrid to get all the
selected(checked) columns?
Tim Wilson - 07 Dec 2004 17:25 GMT
Are you asking how to determine which rows have a certain column value that
is checked in the DataGrid? If so then I assume that the column is bound to
boolean column in the underlying DataTable. So just loop through this
column, in the DataTable, looking for "True" fields.

Signature

Tim Wilson
.Net Compact Framework MVP

> Any pointers as to how to loop through a winforms datagrid to get all the
> selected(checked) columns?
Rekha - 07 Dec 2004 18:59 GMT
yes . i am looking for checked column and get the ID for that checked row.

can u provide me with a sample code, to start with ..

thanks in advance
rekha

> Are you asking how to determine which rows have a certain column value that
> is checked in the DataGrid? If so then I assume that the column is bound to
[quoted text clipped - 3 lines]
> > Any pointers as to how to loop through a winforms datagrid to get all the
> > selected(checked) columns?
Tim Wilson - 07 Dec 2004 19:57 GMT
Here is some code to get you started.

' This code assumes that you have bound a DataTable to the DataSource of a
DataGrid.
' This code also assumes that there is a column named "Bool" that is of type
Boolean.
' This code ensures that in a tri-state check scenario the "Indeterminate"
state is ignored.
Dim dt As DataTable = DirectCast(Me.DataGrid1.DataSource, DataTable)
For Each row As DataRow In dt.Rows
 Dim obj As Object = row("Bool")
 If (TypeOf obj Is Boolean) Then
   If (DirectCast(obj, Boolean) = True) Then
     ' Get ID here.
     ' Example, Dim id As String = DirectCast(row("GUID"), String)
   End If
 End If
Next

Signature

Tim Wilson
.Net Compact Framework MVP

> yes . i am looking for checked column and get the ID for that checked row.
>
[quoted text clipped - 10 lines]
> > > Any pointers as to how to loop through a winforms datagrid to get all the
> > > selected(checked) columns?

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.