CheckBox in gridview

liwaste

Active member
Joined
Oct 7, 2008
Messages
26
Programming Experience
1-3
Hi all,

I am having a gridview bound to a data table.. this datatable has a boolean column and i want to display this column as a check box field.. please let me know how to do this .. and the gridvie can have new rows too.. so any new row added must also have a checkbox field and any selection must be written to the data table and to the database in the end.. this is a vb.net application..
 
I just checked using the code generated using the "Add New Data Source" wizard and by instantiating my own connection through code. In both instances the DataGridView automatically recognized that the bit column should be a CheckBox.

I would suggest starting here Forms over Data Video Series to learn about hooking your application up to a database.
 
:) thanks for the reply

I am building every thing on code.. my data table is filled with an oledb.adapter (yeas am using access) nd the data table is the datasource for my grid.. but i dont know why but .. its not getting the checkbox automatically.. can you gimme the code where you are doin it in code???

i would really appreciate your help

have fun
 
Example using Sql rather than OleDb. You should be able to change them to their Ole counterparts and have them work for you though.

VB.NET:
		Dim ds As New DataSet
		Dim da As New SqlDataAdapter

		Dim connection As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True")
		Using command As New SqlCommand("SELECT * FROM CheckboxTable", connection)
			da.SelectCommand = command
			da.Fill(ds, "TestBitColumn")
		End Using

		Me.DataGridView1.DataSource = ds.Tables("TestBitColumn")
 

Latest posts

Back
Top