Iterating Controls on Tabstrip

Post

Posted
Rating:
#1 (In Topic #1166)
Regular
Andreas_K is in the usergroup ‘Regular’
 Hello, i don't know if i make things wrong:
Iconpanel on a Form, Panel on the Iconpanel, then a Tabstrip on the Panel and then Textfields on the Tabstrip. I Iterate over all controls do change the text in the Textbox.
Only visible Tabs will change the Text, all other dont change the Text…
To solve this, i have to insert the textfields in a panel and iterate every control in the panel, inside the Tabs.
(Sorry for my english..)
Thanks

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
If I understand you correctly, you could give all the TextBoxes the same Action name: -

<IMG src="https://www.cogier.com/gambas/ActionProperty.png"> </IMG>

Then delete all your code and replace with:-

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.   Action["AllTBs"].Text = "OK"
  4.  

Let us know if I have not understood you correctly.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
Andreas_K is in the usergroup ‘Regular’
Thanks, but this was only a example to show this. I update Database Fields with this system…

Code (gambas)

  1. Public Sub SaveData(MyObject As Object, sTable As String, sID As String, Optional sSql As String = "")
  2.  
  3.   Application.Busy = 1
  4.  
  5.   Dim Res As Result
  6.   Dim ctrl As Control
  7.  
  8.   If sid <> "" Then
  9.     'Edit
  10.     Try res = db.Edit(sTable, "id ='" & sid & "'")
  11.  
  12.     For Each ctrl In MyObject.Children
  13.  
  14.       Select Case Object.Type(ctrl)
  15.  
  16.         Case "TextBox"
  17.           If ctrl.Tag <> "id"
  18.             res[ctrl.Tag] = TextBox(ctrl).text
  19.           End If
  20.         Case "ComboBox"
  21.           res[ctrl.Tag] = ComboBox(ctrl).text
  22.         Case "ComboSeek"
  23.           res[ctrl.Tag] = ComboSeek(ctrl).text
  24.         Case "CheckBox"
  25.           res[ctrl.Tag] = CheckBox(ctrl).value
  26.         Case "DateBox"
  27.           res[ctrl.tag] = DateBox(ctrl).value
  28.         Case "ValueBox"
  29.           res[ctrl.Tag] = ValueBox(ctrl).value
  30.         Case "TextArea"
  31.           res[ctrl.Tag] = TextArea(ctrl).text
  32.           ' Case "TabStrip"
  33.           '   SaveDataSubdetail(ctrl, ByRef Res)
  34.       End Select
  35.  
  36.     Next
  37.  
  38.     'Save
  39.     res.Update
  40.  
  41.   Else
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
Try making ctrl an Object not Control with your For loop

I do not know of this TextBox(ctrl).Text syntax you are using?

like this…

Code (gambas)

  1.  
  2.   Dim ctrl As Object  ' Use Object here not Control
  3.  
  4.   If sid <> "" Then
  5.     'Edit
  6.     Try res = db.Edit(sTable, "id ='" & sid & "'")
  7.  
  8.     For Each ctrl In MyObject.Children
  9.  
  10.       Select Case Object.Type(ctrl)
  11.  
  12.         Case "TextBox"
  13.           If ctrl.Tag <> "id"
  14.             res[ctrl.Tag] = ctrl.text
  15.           End If
  16.         Case "ComboBox"
  17.           res[ctrl.Tag] = ctrl.text
  18.         Case "ComboSeek"
  19.           res[ctrl.Tag] = ctrl.text
  20.         Case "CheckBox"
  21.           res[ctrl.Tag] = ctrl.value
  22.         Case "DateBox"
  23.           res[ctrl.tag] = ctrl.value
  24.         Case "ValueBox"
  25.           res[ctrl.Tag] = ctrl.value
  26.         Case "TextArea"
  27.           res[ctrl.Tag] = ctrl.text
  28.           ' Case "TabStrip"
  29.           '   SaveDataSubdetail(ctrl, ByRef Res)
  30.       End Select
  31.  
  32.     Next
  33.  
  34.  
  35.  


See i use ctrl as Object , this means things like ctrl.Text become usable as Object can be anything and ANY property name can be used and accessed if it exists , but Control.class is limited to only use native Control.class properties that does not have .Text, .Value, etc.
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
Andreas_K is in the usergroup ‘Regular’
Thanks, i changed....
Online now: No Back to the top
1 guest and 0 members have just viewed this.