Edoardo_95
Advanced Member
Fatto
Codice:
Public Class cltSelRuote
Private Check() As clsChekBoxModificata
Private Const nCheck As Integer = 12
Private mBackColorNormale As Color = SystemColors.Control
Private mBackColorSelected As Color = Color.Red
Private mForeColorNormale As Color = SystemColors.WindowText
Private mForeColorSelected As Color = Color.White
Public Property BackColorNormale As Color
Get
Return mBackColorNormale
End Get
Set(value As Color)
mBackColorNormale = value
End Set
End Property
Public Property BackColorSelected As Color
Get
Return mBackColorSelected
End Get
Set(value As Color)
mBackColorSelected = value
End Set
End Property
Public Property ForeColorNormale As Color
Get
Return mForeColorNormale
End Get
Set(value As Color)
mForeColorNormale = value
End Set
End Property
Public Property ForeColorSelected As Color
Get
Return mForeColorSelected
End Get
Set(value As Color)
mForeColorSelected = value
End Set
End Property
Private Sub cltSelRuote_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadCampi()
End Sub
Sub LoadCampi()
Dim nX As Integer, nY As Integer
Dim nHTxt As Integer = 15, nWTxt As Integer = 25
Dim Altezza As Integer = 21, Larghezza As Integer = 35
Dim nLeft As Integer = 10
ReDim Check(nCheck)
nX = 0
nY = 0
Dim aRuote() = {"", "Ba", "Ca", "Fi", "Ge", "Mi", "Na", "Pa", "Rm", "To", "Ve", "Nz", "TT"}
Me.Controls.Clear()
For r As Integer = 1 To nCheck
Check(r) = New clsChekBoxModificata
With Check(r)
.AutoSize = False
.Checked = False
.Left = nX
.Top = nY
.Width = Larghezza
.Height = Altezza
.BackColorSelected = mBackColorSelected
.ForeColorSelected = ForeColorSelected
.ForeColorNormale = mForeColorNormale
.TextAlign = ContentAlignment.MiddleCenter
.Appearance = Appearance.Button
.Text = aRuote(r)
Me.Controls.Add(Check(r))
AddHandler Check(r).CheckStateChanged, AddressOf Gestione_CheckstateChanged
.Visible = True
End With
nX = nX + Larghezza
Next
End Sub
Private Sub Gestione_CheckstateChanged(sender As Object, e As EventArgs)
End Sub
Function GetRuoteSelezionate(ByRef aRetRuote() As Integer) As Integer
Dim i As Integer
ReDim aRetRuote(nCheck) ' dimensiono al massimo possibile
For x As Integer = 1 To nCheck
If Check(x).Checked = True Then
i += 1
aRetRuote(i) = x ' giusto
End If
Next
ReDim Preserve aRetRuote(i) ' ridimensiono al numero di ruote trovate
Return i
End Function
Function GetRuoteSelezionate(ByRef aRetRuote() As Boolean) As Integer
Dim i As Integer
ReDim aRetRuote(nCheck) ' dimensiono al massimo possibile
For x As Integer = 1 To nCheck
If Check(x).Checked = True Then
i += 1
aRetRuote(x) = True
End If
Next
Return i
End Function
Sub SetRuoteSelezionate(aRuote() As Integer)
For x As Integer = 1 To UBound(aRuote)
Check(aRuote(x)).Checked = True
Next
End Sub
Sub SetRuoteSelezionate(aRuote() As Boolean)
For x As Integer = 1 To UBound(aRuote)
Check(x).Checked = aRuote(x)
Next
End Sub
End Class