[Gambas-user] Help in new UserControl's Click event
Fabien Bodard
gambas.fr at gmail.com
Sat Oct 21 14:23:25 CEST 2023
That 's what I was pointing
Le sam. 21 oct. 2023 à 14:08, Bruce Steers <bsteers4 at gmail.com> a écrit :
> using GetParent().$Value sets the public variable (that should be private)
> but does not run the Value_Write() method that fires your Click event.
>
>
> On Sat, 21 Oct 2023 at 13:03, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>> try using GetParent().Value not GetParent.$Value this...
>>
>> Public Sub rboptfir_Click()
>>
>> GetParent().Value = rboptfir.Text
>>
>> End
>>
>> Public Sub rboptsec_Click()
>>
>> GetParent().Value = rboptsec.Text
>>
>> End
>>
>> that uses the proper Property not the internal variable
>>
>>
>> On Sat, 21 Oct 2023 at 12:52, Safiur Rahman <isafiur at gmail.com> wrote:
>>
>>> Hi
>>>
>>> Can you provide the updated code which works.
>>>
>>> On Sat, Oct 21, 2023 at 3:41 PM 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
>>>>
>>>
>>>
>>> --
>>> Regards
>>> Safiur Rahman
>>>
>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>>
>>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231021/74b8ff77/attachment.htm>
More information about the User
mailing list