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

Bruce Steers bsteers4 at gmail.com
Sat Oct 21 12:38:49 CEST 2023


a Click event is not native to UserControl
You must use the UserControl_MouseUp event

then inside MouseUp raise the Click event if you want it.

BruceS



On Sat, 21 Oct 2023 at 10:57, Safiur Rahman <isafiur at gmail.com> wrote:

> 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
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231021/280fbdeb/attachment.htm>


More information about the User mailing list