DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Checkbox in DataGridView (http://www.daniweb.com/forums/thread102773.html)

ProfessorPC Dec 29th, 2007 12:02 am
Checkbox in DataGridView
 
Hello,
I am having an issue trying to add a checkbox field to my DataGrid. I have the following Code but it does not display my checkbox. Any help is greatly appreciated.

        Dim myconnection1 As New SqlConnection(myconn)
        Dim dtcCheck As New DataColumn("Select")
        dtcCheck.DataType = System.Type.GetType("System.Boolean")
        dtcCheck.DefaultValue = False
        Dim sa As New SqlDataAdapter("SELECT * FROM therapy", myconnection1)
        sa.Fill(ds, "Therapy")
        DataGridView1.DataSource = ds.Tables("Therapy")
        ds.Tables.Add.Columns.Add(dtcCheck)

Thank You

ptaylor965 Dec 29th, 2007 8:10 am
Re: Checkbox in DataGridView
 
I used this code to create a table with each month as a checkbox
        Dim chkBox As System.Type = System.Type.GetType("System.Boolean")
        With dtYear.Columns
            .Add("Jan", chkBox)
            .Add("Feb", chkBox)
            .Add("Mar", chkBox)
            .Add("Apr", chkBox)
            .Add("May", chkBox)
            .Add("Jun", chkBox)
            .Add("Jul", chkBox)
            .Add("Aug", chkBox)
            .Add("Sep", chkBox)
            .Add("Oct", chkBox)
            .Add("Nov", chkBox)
            .Add("Dec", chkBox)
        End With

Try using this syntax


All times are GMT -4. The time now is 6:51 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC