Datagrid Checkbox is not getting binded to dataset/ access database
-
I have followed another tutorial on adding checkboxes to datagrids and have gotten it to show up. The problem is that I cannot get the checkbox column to bind to my dataset column. I alway see gray checkboxes when I run. All of the other columns are binding correctly. Anyone know what I am doing wrong? Here is the code
DataGridTableStyle tableStyle = new DataGridTableStyle(); //specify the table from dataset (required step) tableStyle.MappingName = "Invoice"; //STEP 2: Create a string column and add it to the tablestyle DataGridColumnStyle DateColumn = new DataGridTextBoxColumn(); DateColumn.MappingName = "Date"; //from dataset table DateColumn.HeaderText = "Date"; DateColumn.Width = 200; tableStyle.GridColumnStyles.Add(DateColumn); DataGridColumnStyle InvoiceNumberColumn = new DataGridTextBoxColumn(); InvoiceNumberColumn.MappingName = "InvoiceNumber"; //from dataset table InvoiceNumberColumn.HeaderText = "Invoice Number"; InvoiceNumberColumn.Width = 200; tableStyle.GridColumnStyles.Add(InvoiceNumberColumn); DataGridColumnStyle RackNumberColumn = new DataGridTextBoxColumn(); RackNumberColumn.MappingName = "RackNumber"; //from dataset table RackNumberColumn.HeaderText = "Rack Number"; RackNumberColumn.Width = 100; tableStyle.GridColumnStyles.Add(RackNumberColumn); /\* DataGridColumnStyle PhoneNumberColumn = new DataGridTextBoxColumn(); PhoneNumberColumn.MappingName = "PhoneNumber"; //from dataset table PhoneNumberColumn.HeaderText = "Phone Number"; PhoneNumberColumn.Width = 200; tableStyle.GridColumnStyles.Add(PhoneNumberColumn); \*/ //STEP 4: Add the checkbox DataGridColumnStyle PaidColumn = new DataGridBoolColumn(); PaidColumn.MappingName = "Paid"; PaidColumn.HeaderText = "Paid"; ((DataGridBoolColumn)PaidColumn).AllowNull = false; //PaidColumn.TrueValue=true; //PaidColumn.FalseValue=false; PaidColumn.Width = 100; tableStyle.GridColumnStyles.Add(PaidColumn); DataGridColumnStyle PickedUpColumn = new DataGridBoolColumn(); PickedUpColumn.MappingName = "PickedUp"; PickedUpColumn.HeaderText = "Picked Up"; ((DataGridBoolColumn)PickedUpColumn).AllowNull = false; PickedUpColumn.Width = 100; tableStyle.GridColumnStyles.Add(PickedUpColumn); //STEP 5: Add the tablestyle to your datagrid's tablestlye collection myDataGrid.TableStyles.Add(tableStyle);
[IMG]http://i40.tinypic.com/34fo65j.jpg\[/IMG\] Here is a snapshot of my A
-
I have followed another tutorial on adding checkboxes to datagrids and have gotten it to show up. The problem is that I cannot get the checkbox column to bind to my dataset column. I alway see gray checkboxes when I run. All of the other columns are binding correctly. Anyone know what I am doing wrong? Here is the code
DataGridTableStyle tableStyle = new DataGridTableStyle(); //specify the table from dataset (required step) tableStyle.MappingName = "Invoice"; //STEP 2: Create a string column and add it to the tablestyle DataGridColumnStyle DateColumn = new DataGridTextBoxColumn(); DateColumn.MappingName = "Date"; //from dataset table DateColumn.HeaderText = "Date"; DateColumn.Width = 200; tableStyle.GridColumnStyles.Add(DateColumn); DataGridColumnStyle InvoiceNumberColumn = new DataGridTextBoxColumn(); InvoiceNumberColumn.MappingName = "InvoiceNumber"; //from dataset table InvoiceNumberColumn.HeaderText = "Invoice Number"; InvoiceNumberColumn.Width = 200; tableStyle.GridColumnStyles.Add(InvoiceNumberColumn); DataGridColumnStyle RackNumberColumn = new DataGridTextBoxColumn(); RackNumberColumn.MappingName = "RackNumber"; //from dataset table RackNumberColumn.HeaderText = "Rack Number"; RackNumberColumn.Width = 100; tableStyle.GridColumnStyles.Add(RackNumberColumn); /\* DataGridColumnStyle PhoneNumberColumn = new DataGridTextBoxColumn(); PhoneNumberColumn.MappingName = "PhoneNumber"; //from dataset table PhoneNumberColumn.HeaderText = "Phone Number"; PhoneNumberColumn.Width = 200; tableStyle.GridColumnStyles.Add(PhoneNumberColumn); \*/ //STEP 4: Add the checkbox DataGridColumnStyle PaidColumn = new DataGridBoolColumn(); PaidColumn.MappingName = "Paid"; PaidColumn.HeaderText = "Paid"; ((DataGridBoolColumn)PaidColumn).AllowNull = false; //PaidColumn.TrueValue=true; //PaidColumn.FalseValue=false; PaidColumn.Width = 100; tableStyle.GridColumnStyles.Add(PaidColumn); DataGridColumnStyle PickedUpColumn = new DataGridBoolColumn(); PickedUpColumn.MappingName = "PickedUp"; PickedUpColumn.HeaderText = "Picked Up"; ((DataGridBoolColumn)PickedUpColumn).AllowNull = false; PickedUpColumn.Width = 100; tableStyle.GridColumnStyles.Add(PickedUpColumn); //STEP 5: Add the tablestyle to your datagrid's tablestlye collection myDataGrid.TableStyles.Add(tableStyle);
[IMG]http://i40.tinypic.com/34fo65j.jpg\[/IMG\] Here is a snapshot of my A
Also, I am getting: 'System.Windows.Forms.DataGridColumnStyle' does not contain a definition for 'TrueValue' 'System.Windows.Forms.DataGridColumnStyle' does not contain a definition for 'FalseValue' Using dotnet 1.1. Anyone know how to solve this?
-
Also, I am getting: 'System.Windows.Forms.DataGridColumnStyle' does not contain a definition for 'TrueValue' 'System.Windows.Forms.DataGridColumnStyle' does not contain a definition for 'FalseValue' Using dotnet 1.1. Anyone know how to solve this?
figured it out, i was not using a bool to bring in the database, rather a string