[Gambas-user] Help in new UserControl's Click event

Safiur Rahman isafiur at gmail.com
Sat Oct 21 11:56:05 CEST 2023


Hello

I am trying to learn how to create a simple user control in gambas. The new
control consists of two RadioButtons arranged Horizontally. When I click
any of the two RadioButton the radioButton's Text becomes the new control's
value and also any of the radiobutton's click event becomes the new
control's click event.

However, on clicking radio button doesn't fire the new control's click event
I am creating new UserControl called "TwoRadio"

''----------- TwoRadio ---------------------------
Export
Inherits UserControl

Public Const _Properties As String = "*,Value"
Property Value As String
Event Click

Private $hForm As FmTwoRadio
Public $Value As String

Public Sub _new()
  $hForm = New FmTwoRadio(Me)
End

Private Function Value_Read() As String
  Return $Value
End

Private Sub Value_Write(Value As String)
  $Value = Value
  Raise Click
End

''------------------- fmTwoRadio -------------------
Private Sub GetParent() As TwoRadio
  Return Me.Parent
End

Public Sub rboptfir_Click()
  GetParent().$Value = rboptfir.Text
End

Public Sub rboptsec_Click()
  GetParent().$Value = rboptsec.Text
End
''-------------- complete ---------------------

Now when I put the new user control "TwoRadio1" and a TextBox "TextBox1" in
FMain form:

Public Sub TwoRadio1_Click()
  TextBox1.Text = TwoRadio1.Value
End

This does not show radiobutton's text in the textbox.  Attached a project

-- 
Regards
Safiur Rahman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231021/6fbfe10f/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newcontrol.zip
Type: application/zip
Size: 15922 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231021/6fbfe10f/attachment-0001.zip>


More information about the User mailing list