Datagrid Query - Unable to find state of checkbox 
Author Message
 Datagrid Query - Unable to find state of checkbox

Dear Sir

Given Below is a Code for a DataGrid with a Column as DataGridBoolColumn.
I have placed a Button on the Form at the Click event. I need the value if
the Checkbox
is Checked or not in a Cell. The Below code throws a error that DataGrid1(i,
0) is DBnull.
When I click the Button

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim WithEvents Data1 As New DataGridBoolColumn()

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

        Dim DBTable As New DataTable("Control")
        Dim Strar(2) As String
        Strar(0) = "Name"
        Strar(1) = "ControlCol"
        Strar(2) = "Description"

        Dim i As Integer
        For i = i To 2
            Dim DBFD As New DataColumn(Strar(i))
            DBFD.DefaultValue = ""
            DBFD.DataType = System.Type.GetType("System.String")

            DBTable.Columns.Add(DBFD)

        Next
        DBTable.TableName = "Control"

        DataGrid1.DataSource = DBTable

        i = 0
        For i = i To 3
            DBTable.LoadDataRow(Strar, True)
            DataGrid1(i, 0) = "My Name is Joe"
            DataGrid1(i, 1) = "This is a Control Col but oh well"
            DataGrid1(i, 2) = "Some description"

        Next

        Dim dgdtblStyle As New DataGridTableStyle()
        dgdtblStyle.MappingName = "Control"

        Data1.MappingName = "Name"
        Data1.HeaderText = "Name"
        Data1.AllowNull = True
        dgdtblStyle.GridColumnStyles.Add(Data1)

        DataGrid1.TableStyles.Clear()
        DataGrid1.TableStyles.Add(dgdtblStyle)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        Dim i As Int16 = 0

        For i = i To 3
            MsgBox(DataGrid1(i, 0))
        Next

    End Sub
End Class

Please suggest a solution

Regards
Devesh



Fri, 28 Jan 2005 22:36:26 GMT  
 Datagrid Query - Unable to find state of checkbox
Thanks Guys Got it.

Devesh

Quote:
> Dear Sir

> Given Below is a Code for a DataGrid with a Column as DataGridBoolColumn.
> I have placed a Button on the Form at the Click event. I need the value if
> the Checkbox
> is Checked or not in a Cell. The Below code throws a error that
DataGrid1(i,
> 0) is DBnull.
> When I click the Button

> Public Class Form1
>     Inherits System.Windows.Forms.Form

>     Dim WithEvents Data1 As New DataGridBoolColumn()

>     Private Sub Form1_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)

>         Dim DBTable As New DataTable("Control")
>         Dim Strar(2) As String
>         Strar(0) = "Name"
>         Strar(1) = "ControlCol"
>         Strar(2) = "Description"

>         Dim i As Integer
>         For i = i To 2
>             Dim DBFD As New DataColumn(Strar(i))
>             DBFD.DefaultValue = ""
>             DBFD.DataType = System.Type.GetType("System.String")

>             DBTable.Columns.Add(DBFD)

>         Next
>         DBTable.TableName = "Control"

>         DataGrid1.DataSource = DBTable

>         i = 0
>         For i = i To 3
>             DBTable.LoadDataRow(Strar, True)
>             DataGrid1(i, 0) = "My Name is Joe"
>             DataGrid1(i, 1) = "This is a Control Col but oh well"
>             DataGrid1(i, 2) = "Some description"

>         Next

>         Dim dgdtblStyle As New DataGridTableStyle()
>         dgdtblStyle.MappingName = "Control"

>         Data1.MappingName = "Name"
>         Data1.HeaderText = "Name"
>         Data1.AllowNull = True
>         dgdtblStyle.GridColumnStyles.Add(Data1)

>         DataGrid1.TableStyles.Clear()
>         DataGrid1.TableStyles.Add(dgdtblStyle)

>     End Sub

>     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>         Dim i As Int16 = 0

>         For i = i To 3
>             MsgBox(DataGrid1(i, 0))
>         Next

>     End Sub
> End Class

> Please suggest a solution

> Regards
> Devesh



Fri, 28 Jan 2005 22:56:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Datagrid checkbox not showing changed state.

2. Dynamically Added Datagrid Template Column - Checkbox.Checked state in Column Header

3. Checkbox query in Datagrid

4. Checkbox format in datagrid not showing checkboxes

5. Checkbox format in datagrid not showing checkboxes

6. Unable to delete from query if more than one table in query

7. Three State Web Checkbox?

8. Three state checkbox in listview

9. Checkbox state Question

10. Checkbox and TextBox Not Maintaining State on PostBack

11. Checkboxes in Treeviews with Three States

12. 3 State Checkbox Control (fwd)

 

 
Powered by phpBB® Forum Software