Dim ob As Object
For Each ob In Me.Children
If Object.Type(ob) = "Button" Then ob.Visible = False
Next
oHBox As HBox
oButton As Button
oSpring As Spring
Slider1 As Slider
Label1 As Label
bButtonList As New Button[]
Public Sub Form_Open()
CreateForm
End
Public Sub Slider1_Change()
Dim iLoop As Integer
For iLoop = 0 To bButtonList.Max
If bButtonList[iLoop].Tag > Slider1.Value Then
bButtonList[iLoop].Visible = False
Else
bButtonList[iLoop].Visible = True
Endif
Next
Me.Text = "Slider1.Value = " & Str(Slider1.Value)
End
1000
Public Sub AllButtons_Click()
Label1.Text = Last.Text
End
Public Sub CreateForm()
Dim iBut, iBox, iCount As Integer
With Me
.Height = 400
.Width = 750
.Arrangement = Arrange.Vertical
.Padding = 15
End With
With Slider1 = New Slider(Me) As "Slider1"
.Height = 35
.Width = 100
.MaxValue = 20
.MinValue = 0
.Mark = True
.Value = 20
End With
For iBox = 0 To 4
With OHBox = New HBox(Me)
.Height = 25
.Width = 100
End With
For iBut = 0 To 3
With oButton = New Button(oHBox) As "AllButtons"
Inc iCount
.Text = "Button" & Str(iCount)
.Width = 124
.Height = 35
.Tag = iCount
End With
If iBut < 3 Then oSpring = New Spring(oHbox)
bButtonList.Add(oButton)
Next
Next
oSpring = New Spring(Me)
With Label1 = New Label(Me) As "Label1"
.Height = 35
.Width = 100
.Alignment = Align.Center
.Font.Bold = True
.Text = "Button_Click()"
End With
End
(22-08-2023, 03:19)playmepe escribió: si solamente quisiera ocultar algunosPor lo general, puedes operar distinguiendo los "Botones" individuales, haciendo referencia a sus Propiedades (por ejemplo, el nombre ".Name" o su posición .X o .Y en el Formulario, u otras).
Private butt As Button
Public Sub Form_Open()
For b As Byte = 0 To 3
With butt = New Button(Me) As "Boton"
.W = 100
.H = 40
.X = .W * b
.Y = 200
.Name = .Name & CStr(b)
' Veamos en console por curiosidad el ".Name" de cada Botón:
Print .Name
End With
Next
End
Public Sub Form_MouseUp()
Dim ob As Object
For Each ob In Me.Children
If Object.Type(ob) = "Button" Then
If Val(Right(ob.Name, 1)) > 1 Then ob.Visible = False
Endif
Next
End