[Gambas-user] Question to controls

Bruce Steers bsteers4 at gmail.com
Sun Oct 4 14:57:53 CEST 2020


Do you know of the "Last" property?

Any event call like GotFocus() comes with the "Last" property.
it will be the object that called the event regardless of it's name.
(also "Control" may lack some properties you wish to access unique to a
TextBox, if so try "Object" instead or even better if you know the type of
control use that explicitly)
Ie.

*Public ctrl As Control*

*Public obj As Object*

*Public Sub DA_nachname_GotFocus()*
*  ctrl = Last*
*  obj = Last*
*End*

Or
(using this method will give you ALL the available textbox properties)


*Public ctrlTBox As TextBox*

*Public Sub DA_nachname_GotFocus()*
*  ctrlTBox = Last*
*End*

BruceS

On Sun, 4 Oct 2020 at 13:13, Dag Jarle Nerland Johansen - Gambas <
gambas at cd-bahia.com> wrote:

> Hi,
>
> I have some textboxes on a form.
> To simplify some actions I wanted to use a virtual control defined as
>
> *Public ctrl As Control*
>
> On each of the textboxes I make f.ex.
>
> *Public Sub DA_nachname_GotFocus()*
> *  ctrl = DA_nachname*
> *End*
>
> I thought, when I have set this, I can use all properties of the current
> control. Especially I wanted to use the value or text.
> But that does not exist, either *ctrl.Value* nor *ctrl.Tex*t. Most other
> properties though, but those doesn't help in this case.
>
> Also, is there a better way to catch the current control without naming
> it? I did not find in the docs I searched.
> As f.ex ctrl=control.current?
>
> I don't want to need all the theory of OOP, I only now and then program,
> but want to make it easier though.
> (Already retired)
>
> Thanks in advance
> Dag
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201004/74c77937/attachment-0001.htm>


More information about the User mailing list