[Gambas-user] How do you set text for a group of textbox ?

Steven James Drinnan steven at ...2097...
Mon Jun 29 07:21:22 CEST 2009



On Fri, 2009-06-26 at 15:41 -0700, Swee Kwang Tan wrote:
> Dear Sir, 
> If I have a group of textbox, a string array access data from database, How do I write a 
> program to set text for each textbox sepqrately ? like the following
> dim str[10] as string
> dim i as integer
> .....
> .....      'after this line, str get the data from database 
> for i = 0 to 9
>          myTextBoxGroup[tag].text = str[i]
> next
> This is the last question, I have't other problem now.
> Thank  you
> 
> 
> _______________________________________
>  辣茩妏蚚閉湮⺍講捇誥蚘眊 
>  http://cn.mail.yahoo.com 
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

Group is used to assassin a common event handler any control that has
that group name will that code first. i.e if a group is named 'n' then
the key press event would be

public sub n_keypress()

to find the control that fired this event use the LAST key word


But this may help.


You could try putting the controls into an object array like this
Dim myTextBoxGroup as Object[10] 'this makes an array of 10 for ten text
boxes.

DIM mycontrol AS Object
  
  
  
  FOR EACH mycontrol IN ME.Controls
    IF mycontrol IS TextBox THEN 
      'you can put other conditionals here
      
      TRY myTextBoxGroup.Add mycontrol
    END IF


then you can use your code below.
Dim curTextBox as Textbox
dim str[10] as string 
dim i as integer

for i = 0 to 9
curTextBox = myTextBoxGroup[tag] 'changes it to the correct type
        curtextBox.text = str[i] 
next


P.S what is tag





More information about the User mailing list