Radio button binding

  • Thread starter Thread starter Savvas
  • Start date Start date
S

Savvas

Dear Cor Ligthert

My account is not yet validated so i cannot log in to reply directly to
you.

An analogy of what i need is the following:
Say e.g. you have a groub box "Sex" and two radio buttons "Male" and
"Female".
When you recall the form to edit the information of the person to
change from male to female :) what is the binding i have to make. From
the properties i cannot do data binding cause there are two radio
buttons.

Thanks again
 
Savvas

Your value is not Sex = true in my opinion, however Male = true and
therefore female is false.

The behaviour of a radiobutton in a groupbox is pretty for that.

See this sample. it needs only two radiobuttons in a groupbox and a button
on a form.
\\\\
Dim dt As New DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
dt.Columns.Add("Male", GetType(System.Boolean))
dt.LoadDataRow(New Object() {True}, True)
RadioButton1.DataBindings.Add("Checked", dt, "Male")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
BindingContext(dt).EndCurrentEdit()
MessageBox.Show(dt.Rows(0).ItemArray(0).ToString)
End Sub
///

I hope this helps,

Cor
 
Back
Top