Edoardo_95
Advanced Member
Codice:
Public Class cltSelPosizione
Private Check() As clsChekBoxModificata
Private Const nCheck As Integer = 5
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
LoadCampi()
End Set
End Property
Public Property BackColorSelected As Color
Get
Return mBackColorSelected
End Get
Set(value As Color)
mBackColorSelected = value
LoadCampi()
End Set
End Property
Public Property ForeColorNormale As Color
Get
Return mForeColorNormale
End Get
Set(value As Color)
mForeColorNormale = value
LoadCampi()
End Set
End Property
Public Property ForeColorSelected As Color
Get
Return mForeColorSelected
End Get
Set(value As Color)
mForeColorSelected = value
LoadCampi()
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() = {"", "1", "2", "3", "4", "5"}
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
.ForeColorNormale = mForeColorNormale
.BackColorNormale = mBackColorNormale
.BackColorSelected = mBackColorSelected
.ForeColorSelected = mForeColorSelected
.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 GetPosizioniSelezionate(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 GetPosizioniSelezionate(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 SetPosizioniSelezionate(aRuote() As Integer)
For x As Integer = 1 To UBound(aRuote)
Check(aRuote(x)).Checked = True
Next
End Sub
Sub SetPosizioniSelezionate(aRuote() As Boolean)
For x As Integer = 1 To UBound(aRuote)
Check(x).Checked = aRuote(x)
Next
End Sub
End Class