Ciao; ho dovuto rivoluzionare un pò tutto, ma così è fichissimo!
Questa è la creazione:
PUBLIC SUB Set_Buttons()
DIM sql AS String
DIM fList AS Float
DIM btn AS Button
DIM i AS Integer
FOR i = 1 TO 300
IF i < 51 THEN btn = NEW Button(Panel4) AS "myBtn"
IF i > 50 AND i < 101 THEN btn = NEW Button(Panel5) AS "myBtn"
IF i > 100 AND i < 151 THEN btn = NEW Button(Panel6) AS "myBtn"
IF i > 150 AND i < 201 THEN btn = NEW Button(Panel7) AS "myBtn"
IF i > 200 AND i < 251 THEN btn = NEW Button(Panel8) AS "myBtn"
IF i > 250 THEN btn = NEW Button(Panel9) AS "myBtn"
btn.Height = 59
btn.Width = 98
btn.Name = i
sql = "SELECT * FROM tconfbtn WHERE id = " & i
MyRes = modConn.$Conn.Exec(sql)
IF MyRes.Available THEN
IF RadioButton1.Value THEN
TRY fList = MyRes!list1
ELSE IF RadioButton2.Value THEN
TRY fList = MyRes!list2
ELSE IF RadioButton3.Value THEN
TRY fList = MyRes!list3
ELSE IF RadioButton4.Value THEN
TRY fList = MyRes!list4
ENDIF
IF MyRes!text2 = NULL THEN
btn.Text = MyRes!text & gb.NewLine & " € " & modZero.PiuZero(fList)
ELSE
btn.Text = MyRes!text & gb.NewLine & MyRes!text2 & gb.NewLine & " € " & modZero.PiuZero(fList)
ENDIF
WITH btn
.Background = MyRes!bkgnd
.Foreground = MyRes!fognd
.Font.Name = MyRes!fntno
.Font.Bold = MyRes!fntbo
.Font.Italic = MyRes!fntit
.Font.Size = MyRes!fntsi
.Font.StrikeOut = MyRes!fntso
.Font.Underline = MyRes!fntul
END WITH
ELSE
btn.Text = NULL
ENDIF
NEXT
END
E questa è la modifica in corsa:
' Scorriamo tutte e 6 le tabelle
FOR EACH objA IN FMain.TabStrip1.Children
' Prendiamo in considerazione tutti i Button
' presenti nell PanelX:
FOR EACH objB IN objA.Children
' Quando il codice passa a considerare il Button (Children) num. X, allora...
IF objB.name = FMain.inBtn THEN
'...gli cambiamo qualche connotato...:
WITH objB
.Background = btnExe.Background
.Foreground = btnExe.Foreground
.Font.Name = btnExe.Font.Name
.Font.Bold = fntbo
.Font.Italic = fntit
.Font.Size = btnExe.Font.Size + 1
.Font.StrikeOut = fntso
.Font.Underline = fntul
END WITH
IF TextBox2.Text = NULL THEN
objB.Text = TextBox1.Text & gb.NewLine & " € " & TxtPrezzo1.Text
ELSE
objB.Text = TextBox1.Text & gb.NewLine & TextBox2.Text & gb.NewLine & " € " & TxtPrezzo1.Text
ENDIF
ENDIF
NEXT
NEXT
Per quanto riguarda la distruzione, usando
ScrollView1.Children.Clear
oppure, come mel mio caso
non và, perchè, in entrambi i casi, dopo Children. accetta solo Count.
GRAZIE!