Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4,VB5,VB6
Expertise: beginner
Jul 1, 2000

Bind a group of OptionButtons to a Data control

You can't directly bind a group of OptionButton controls to a Data control, RDO Data control or ADO Data control. However, you can work around this limitation by adding an hidden TextBox control and add a few lines of code:

Private Sub optRadioButton_Click(Index As Integer)
    ' change the contents of the hidden TextBox control
    txtHidden.Text = Trim$(Index)
End Sub

Private Sub txtHidden_Change()
    ' Select the OptionButton corresponding to the value
    ' that the Data control is assigning to the hidden TextBox
    On Error Resume Next
    optRadioButton(CInt(txtHidden.Text)).Value = True
End Sub
You can use the same trick to indirectly bind any other type of control to a numeric or string database field, for example a scrollbar, the caption of a Frame, the size or position of a Shape control, the position of a Slider control, etc.
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date