no hit when checking checked checkboxes in datagrid

M

magmo

Hi

I try to loop through a datagrid to see if the checkbox in the
datagrid is selected using this code..

<code>
Public Function GetSelectedRows(ByVal dg As DataGrid) As
System.Collections.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager = Me.BindingContext(dg.DataSource,
dg.DataMember)
Dim dv As DataView = CType(cm.List, DataView)
Dim i As Integer
For i = 0 To dv.Count - 1
If dg.IsSelected(i) Then
al.Add(i)
Else
al.Add("no hit no: " & i & vbCrLf)
End If
'End
Next
Return al
End Function 'GetSelectedRows



Private Sub btnMakePDF_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnMakePDF.Click
Dim s As String = ("Selected rows...." & vbCrLf)
Dim o As Object
For Each o In GetSelectedRows(MyDataGrid)
s += " " + o.ToString()
Next o
MessageBox.Show(s)
'MessageBox.Show("Selected items....")
End Sub 'button1_Click
</code>


But it never indicate that a checkbox is selected even though I select
checkboxes. What am I missing here?


Regards


Magnus
 
M

magmo

Hi Ken



Thats very nice of you, Thanks a million! This will get me started.



Regards


Magnus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top