Home All Groups Group Topic Archive Search About

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

Author
7 Dec 2004 4:05 PM
Rekha
Any pointers as to how to loop through a winforms datagrid to get all the
selected(checked) columns?

Author
7 Dec 2004 5:25 PM
Tim Wilson
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.

--
Tim Wilson
..Net Compact Framework MVP

Show quoteHide quote
"Rekha" <Re***@discussions.microsoft.com> wrote in message
news:D22B2EE8-A773-415F-B98C-3F6EC9BAB8F7@microsoft.com...
> Any pointers as to how to loop through a winforms datagrid to get all the
> selected(checked) columns?
Are all your drivers up to date? click for free checkup

Author
7 Dec 2004 6:59 PM
Rekha
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



Show quoteHide quote
"Tim Wilson" wrote:

> 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.
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "Rekha" <Re***@discussions.microsoft.com> wrote in message
> news:D22B2EE8-A773-415F-B98C-3F6EC9BAB8F7@microsoft.com...
> > Any pointers as to how to loop through a winforms datagrid to get all the
> > selected(checked) columns?
>
>
>
Author
7 Dec 2004 7:57 PM
Tim Wilson
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

--
Tim Wilson
..Net Compact Framework MVP

Show quoteHide quote
"Rekha" <Re***@discussions.microsoft.com> wrote in message
news:989BB128-AF8D-4756-A49A-6D60F3BCCA6E@microsoft.com...
> 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
>
>
>
> "Tim Wilson" wrote:
>
> > 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.
> >
> > --
> > Tim Wilson
> > ..Net Compact Framework MVP
> >
> > "Rekha" <Re***@discussions.microsoft.com> wrote in message
> > news:D22B2EE8-A773-415F-B98C-3F6EC9BAB8F7@microsoft.com...
> > > Any pointers as to how to loop through a winforms datagrid to get all
the
> > > selected(checked) columns?
> >
> >
> >

Bookmark and Share