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
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.NET : How Can i Bind data to CheckBox

VB.NET : How Can i Bind data to CheckBox

Scheduled Pinned Locked Moved Visual Basic
csharpwpfwcfsales
1 Posts 1 Posters 0 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.
  • I Offline
    I Offline
    intibnin
    wrote on last edited by
    #1

    I just start to work with VB.NET and i designed a form that allows me editing customer records. The code is as follows : Private Sub BindingFields() con = MyConnection.GetHandler() Mydataset = New DataSet() MyAdapter = New SqlClient.SqlDataAdapter("select * from client", con) MyBuilder = New SqlClient.SqlCommandBuilder(MyAdapter) MyAdapter.Fill(Mydataset, "client") TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_codcli")) TextBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_adrcli")) TextBox3.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_tel1")) TextBox4.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_nomcli")) TextBox5.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_tel2")) TextBox6.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_fax")) TextBox7.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_datcre")) TextBox10.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_remcli")) CheckBox1.DataBindings.Add(New System.Windows.Forms.Binding("checked", Mydataset, "client.stop_serv")) 'da.Fill(Mydataset, "Categorie") 'ComboBox1.DataSource = Mydataset 'ComboBox1.DisplayMember = "categorie.libelle" End Sub and the code of the AddNew button is as follows : Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click AddRecord() End Sub 'This routine add a blank record Private Sub AddRecord() Mode = "A" Try Me.BindingContext(Mydataset, "client").EndCurrentEdit() Me.BindingContext(Mydataset, "client").AddNew() TextBox1.Text = Getautocode() TextBox4.Focus() Catch eEndEdit As System.Exception System.Windows.Forms.MessageBox.Show(eEndEdit.Message) End Try End Sub Someone can tell me for why the fields don't become empty when i click on the addnew button . whereas, when i disabled the line : CheckBox1.DataBindings.Add(New System.Windows.Forms.Binding("checked", Mydataset, "client.stop_serv")) the code works correctly. Thank you very much. ***

    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