1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
Public Sub EditablePanelAptFormGeneral(ByVal valueTrueOrFalse As Boolean)
Dim c() As Control = {Me.Panel1, Me.Panel3, Me.Panel4, Me.pnlWPrices, Me.pnlMPrices, Me.TabST, Me.TabVST} 'Me.Panel24, Me.Panel26, Me.pnlWPrices1, Me.pnlNPrices, Me.pnlMPrices1
Dim LstTempcontrol As New Generic.List(Of ComboBox)
For Each i As Control In c
For Each CurControl As Control In i.Controls
If (TypeOf CurControl Is TextBox) Then
Dim tempcontrol As TextBox
tempcontrol = (CType(CurControl, TextBox))
tempcontrol.ReadOnly = Not valueTrueOrFalse
ElseIf (TypeOf CurControl Is CheckBox) Then
Dim tempcontrol As CheckBox
tempcontrol = (CType(CurControl, CheckBox))
tempcontrol.AutoCheck = valueTrueOrFalse
ElseIf (TypeOf CurControl Is ComboBox) Then
Dim tempcontrol As ComboBox
tempcontrol = (CType(CurControl, ComboBox))
' tempcontrol.Enabled = valueTrueOrFalse
If Not valueTrueOrFalse Then
If tempcontrol.DropDownStyle = ComboBoxStyle.DropDownList Then 'Test si le combobox est a DropDownList
tempcontrol.DropDownStyle = ComboBoxStyle.DropDown 'passer le combobox au style DropDown
SetComboReadOnly(tempcontrol, Not valueTrueOrFalse)
LstTempcontrol.Add(tempcontrol) 'Construire une lise des combobox qui ont un style DropDownList
Else
SetComboReadOnly(tempcontrol, Not valueTrueOrFalse)
End If
Else
For Each lst In LstTempcontrol 'parcourir la liste des combobox qui ont un style DropDownList
lst.DropDownStyle = ComboBoxStyle.DropDownList 'Remettre le style d'orgine des combobox
Next
SetComboReadOnly(tempcontrol, Not valueTrueOrFalse)
End If
ElseIf (TypeOf CurControl Is RadioButton) Then
Dim tempcontrol As RadioButton
tempcontrol = (CType(CurControl, RadioButton))
tempcontrol.AutoCheck = valueTrueOrFalse
ElseIf (TypeOf CurControl Is DateTimePicker) Then
Dim tempcontrol As DateTimePicker
tempcontrol = (CType(CurControl, DateTimePicker))
tempcontrol.Enabled = valueTrueOrFalse
ElseIf (TypeOf CurControl Is PADatePicker) Then
Dim tempcontrol As PADatePicker
tempcontrol = (CType(CurControl, PADatePicker))
' tempcontrol.Enabled = valueTrueOrFalse
tempcontrol.Read_Only = Not valueTrueOrFalse
ElseIf (TypeOf CurControl Is Button) Then
Dim tempcontrol As Button
tempcontrol = (CType(CurControl, Button))
tempcontrol.Enabled = valueTrueOrFalse
ElseIf (TypeOf CurControl Is DataGridView) Then
Dim tempcontrol As DataGridView
tempcontrol = (CType(CurControl, DataGridView))
tempcontrol.ReadOnly = Not valueTrueOrFalse
ElseIf (TypeOf CurControl Is PictureBox) Then
Dim tempcontrol As PictureBox
tempcontrol = (CType(CurControl, PictureBox))
tempcontrol.Enabled = Not valueTrueOrFalse
End If
Next
Next
end sub |
Partager