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. How can I bind data to Groupbox of radiobuttons

How can I bind data to Groupbox of radiobuttons

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
4 Posts 2 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

    Hi, Please I need help, I have a groupbox that contains 2 radiobuttons. So i want to bind to it a datafield (having only 2 values : 1 for the first radiobutton, or 2 for the second radiobutton). Please can someone show me how to use databinding with this groupbox. Thank you in advance. Intibnin... ***

    T 1 Reply Last reply
    0
    • I intibnin

      Hi, Please I need help, I have a groupbox that contains 2 radiobuttons. So i want to bind to it a datafield (having only 2 values : 1 for the first radiobutton, or 2 for the second radiobutton). Please can someone show me how to use databinding with this groupbox. Thank you in advance. Intibnin... ***

      T Offline
      T Offline
      Tatham
      wrote on last edited by
      #2

      From what I understand in your message, you have: Form - GroupBox - RadioButton1 - RadioButton2 You also have a dataset where each row has 1 column (or more). If this column has a value of 1 you want RadioButton1 to be selected, otherwise RadioButton2. Can you clarify your situation a bit more? Are you using typed/untyped datasets? Are you using C#, VB, or J#? I dont see how this isn't just basic databinding - and if it is you'd be better off checking MSDN for the documentation on DataBinding. Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989

      I 1 Reply Last reply
      0
      • T Tatham

        From what I understand in your message, you have: Form - GroupBox - RadioButton1 - RadioButton2 You also have a dataset where each row has 1 column (or more). If this column has a value of 1 you want RadioButton1 to be selected, otherwise RadioButton2. Can you clarify your situation a bit more? Are you using typed/untyped datasets? Are you using C#, VB, or J#? I dont see how this isn't just basic databinding - and if it is you'd be better off checking MSDN for the documentation on DataBinding. Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989

        I Offline
        I Offline
        intibnin
        wrote on last edited by
        #3

        Thank Tatham for help. Well, the problem i encountred is in VB.NET Form. I try to clarify the problem, so the dataset used in form is filled programmatically. I create a method for binding fields to dataset as follows : Private Sub BindingFields() cn = New SqlClient.SqlConnection(constring) Dim da As New SqlClient.SqlDataAdapter("select * from parametres where type = 1 order by code ", cn) 'Note : Mydataset, MyBuilder and MyAdapter are declared public objects Mydataset = New DataSet() MyAdapter = New SqlClient.SqlDataAdapter("select * from client", cn) 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.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.tel2")) TextBox6.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.fax")) TextBox7.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.dat_cre")) da.Fill(Mydataset, "Categorie") ComboBox1.DataSource = Mydataset ComboBox1.DisplayMember = "Categorie.libelle" ComboBox1.ValueMember = "categorie.cat_cli" '***************************** 'The problem is here 'Client.stop_serv is 1 or 2 '****************************** GroupBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.stop_serv")) End Sub this code does not work. Thank you in advance ***

        T 1 Reply Last reply
        0
        • I intibnin

          Thank Tatham for help. Well, the problem i encountred is in VB.NET Form. I try to clarify the problem, so the dataset used in form is filled programmatically. I create a method for binding fields to dataset as follows : Private Sub BindingFields() cn = New SqlClient.SqlConnection(constring) Dim da As New SqlClient.SqlDataAdapter("select * from parametres where type = 1 order by code ", cn) 'Note : Mydataset, MyBuilder and MyAdapter are declared public objects Mydataset = New DataSet() MyAdapter = New SqlClient.SqlDataAdapter("select * from client", cn) 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.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.tel2")) TextBox6.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.fax")) TextBox7.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.dat_cre")) da.Fill(Mydataset, "Categorie") ComboBox1.DataSource = Mydataset ComboBox1.DisplayMember = "Categorie.libelle" ComboBox1.ValueMember = "categorie.cat_cli" '***************************** 'The problem is here 'Client.stop_serv is 1 or 2 '****************************** GroupBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.stop_serv")) End Sub this code does not work. Thank you in advance ***

          T Offline
          T Offline
          Tatham
          wrote on last edited by
          #4

          Either: RadioButton1.DataBindings.Add(New System.Windows.Forms.Binding("Value", Mydataset, "client.stop_serv1")) RadioButton2.DataBindings.Add(New System.Windows.Forms.Binding("Value", Mydataset, "client.stop_serv2")) Or, can you just use a check box and bind the Checked property? Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989

          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