How can I bind data to Groupbox of radiobuttons
-
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... ***
-
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... ***
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
-
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
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 ***
-
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 ***
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 theChecked
property? Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989