Getting the name of a control on a form

Post

Posted
Rating:
#1 (In Topic #1125)
Trainee
 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
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
If a textarea is all that is on each tab you could do this…

Code (gambas)

  1.  
  2. Dim tArea As TextArea = TabStrip1[TabStrip1.Index].Children[0]
  3.  
  4. tArea.Cut
  5.  
  6.  

Or access it by name this way …

Code (gambas)

  1. Dim tArea As TextArea = Me.Controls("TextArea" & Str(TabStrip1.Index + 1))
  2.  
  3. tArea.Cut
  4.  
  5.  

Or this..

Code (gambas)

  1. Dim tArea As TextArea = Me["TextArea" & Str(TabStrip1.Index + 1)]
  2.  
  3. tArea.Cut
  4.  
  5.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
That works perfectly, thank you.
 :D  :D  :D
Online now: No Back to the top
1 guest and 0 members have just viewed this.