Hello all,
I'm new to Gambas so I am still finding my way around. I have a question that I hope someone can answer for me.
I have a form with a TabStrip on it that contains five tabs. Each tab has a TextArea on it, 1 through 5. If I want to copy text into the TextArea of one of the tabs I have to find out what tab has been selected and then copy or paste into the TextArea;
If TabStrip.Index = 0 then TextArea1.Cut
If TabStrip.Index = 1 then TextArea2.Cut
and so on...
Is there a more elegant way of achieving this?
What I would like is;
Get the name of the TextArea on currently active Tab and put that into variable tArea
and instead of TextArea1.Cut use tArea.Cut
Any suggestions are welcome.
Thanks for reading
Pusherman
Getting the name of a control on a form
- BruceSteers
- Posts: 1582
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Getting the name of a control on a form
If a textarea is all that is on each tab you could do this...
Or access it by name this way ...
Or this..
Dim tArea As TextArea = TabStrip1[TabStrip1.Index].Children[0]
tArea.Cut
Or access it by name this way ...
Dim tArea As TextArea = Me.Controls("TextArea" & Str(TabStrip1.Index + 1))
tArea.Cut
Or this..
Dim tArea As TextArea = Me["TextArea" & Str(TabStrip1.Index + 1)]
tArea.Cut
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: Getting the name of a control on a form
That works perfectly, thank you.