I am new to winforms and I have a datagridview inside a table control. I am trying to bind it to display data.
DataSet dataSet = new DataSet();
DataTable dat
Setting DataSource property will bind datasouce. ASP.NET needs a .DataBind call instead.
For the checkbox you need to add a column of type DataGridViewCheckBoxColumn.
Best resource i found on databind (these are for framework 2.0/VS2005):
http://windowsclient.net/Samples/Go%20To%20Market/Data%20Binding/DataBinding%20FAQ.doc
http://windowsclient.net/Samples/Go%20To%20Market/DataGridView/DataGridView%20FAQ.doc
you only have to add this:
dataGridView1.DataMember = ds.Tables(0).ToString()
As of note, the link BWC's answer gives off incorrect syntax for referencing a datatable from a dataset. You use []'s not ()'s to reference the index of datatables in a DS.
DataSet dataSet = new DataSet();
DataTable dataTable = dataSet.Tables.Add("Results");
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
dataTable.Rows.Add("1","Jack");
dataTable.Rows.Add("2","Donna");
dataGridView1.DataSource = dataSet.Tables["dataTable"]
If you are looking at checkboxes, but not one that is boundto any data, use the property editor of the DataGridView to edit the columns (click on the elipses "..." in that field)
Click on Add, select unbound column, and finally choose the checkbox column type:
http://hodentekhelp.blogspot.com/2008/07/how-to-bind-dataset-to-datagridview.html
This should help with your databinding
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcolumn.aspx
take a look at that for the checkbox column
Here is some sample code
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("Blah",typeof(bool));
dt.Columns.Add("Blah2");
ds.Tables.Add(dt);
dataGridView1.DataSource = ds.Tables[0];