Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Datagrid Checkbox is not getting binded to dataset/ access database

Datagrid Checkbox is not getting binded to dataset/ access database

Scheduled Pinned Locked Moved C#
databasewpfwcfcomhelp
3 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jeweladdict
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • J jeweladdict

      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

      J Offline
      J Offline
      jeweladdict
      wrote on last edited by
      #2

      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?

      J 1 Reply Last reply
      0
      • J jeweladdict

        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?

        J Offline
        J Offline
        jeweladdict
        wrote on last edited by
        #3

        figured it out, i was not using a bool to bring in the database, rather a string

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups