OVH Cloud OVH Cloud

Objets sur une feuille WINDOWS

3 réponses
Avatar
Daniel
Je souhaite pouvoir parcourir les objets d'une feuille=20
WINDOWS
et modifier la hauteur des TEXBOX, des bouttons par=20
programme, pour obtenir
une hauteur uniforme des champs de saisie, ...
Ci-joint =E9bauche d'un PGM VB.NET
Comment =E7=E0 marche ? Merci pour le tuyau !
Daniel

Sub Remapping()
Dim FeuilleCourante As System.Windows.Forms.Form =3D=20
System.Windows.Forms.Form.ActiveForm
Dim Incr=E9ment As Integer
For Incr=E9ment =3D 0 To FeuilleCourante.Controls.Count - 1
' Recherche tous les types de contr=F4le :
select case FeuilleCourante.Controls(Incr=E9ment)
case ?(Zone TextBox)
FeuilleCourante.Controls(Incr=E9ment).height =3D 100
=09
case ?(Boutton de commande)
FeuilleCourante.Controls(Incr=E9ment).height =3D 120
=09
case else=09
End Select=20
Next =20
End Sub

3 réponses

Avatar
Ghislain Proulx
Bonjour Daniel,

Sub Remapping()
Dim FeuilleCourante As System.Windows.Forms.Form System.Windows.Forms.Form.ActiveForm

For Each ctrl As Control In FeuilleCourante
If ctrl.GetType() Is GetType(System.Windows.Forms.TextBox) Then
CType(ctrl,System.Windows.Forms.TextBox).Height = 100
EndIf
If ctrl.GetType() Is GetType(System.Windows.Forms.Button) Then
CType(ctrl,System.Windows.Forms.Button).Height = 120
EndIf
Loop
End Sub

Bonne journée

Ghislain Proulx

"Daniel" a écrit dans le message de
news:923a01c47899$defb0a20$
Je souhaite pouvoir parcourir les objets d'une feuille
WINDOWS
et modifier la hauteur des TEXBOX, des bouttons par
programme, pour obtenir
une hauteur uniforme des champs de saisie, ...
Ci-joint ébauche d'un PGM VB.NET
Comment çà marche ? Merci pour le tuyau !
Daniel

Sub Remapping()
Dim FeuilleCourante As System.Windows.Forms.Form System.Windows.Forms.Form.ActiveForm
Dim Incrément As Integer
For Incrément = 0 To FeuilleCourante.Controls.Count - 1
' Recherche tous les types de contrôle :
select case FeuilleCourante.Controls(Incrément)
case ?(Zone TextBox)
FeuilleCourante.Controls(Incrément).height = 100

case ?(Boutton de commande)
FeuilleCourante.Controls(Incrément).height = 120

case else
End Select
Next
End Sub
Avatar
Un nouveau message apparaît à l'exécution du code

Expression is of type 'System.Windows.Forms.Form', which
is not a collection type.

Où est l'erreur ?
Daniel


-----Message d'origine-----
Bonjour Daniel,

Sub Remapping()
Dim FeuilleCourante As System.Windows.Forms.Form =
System.Windows.Forms.Form.ActiveForm

For Each ctrl As Control In FeuilleCourante
If ctrl.GetType() Is GetType


(System.Windows.Forms.TextBox) Then
CType(ctrl,System.Windows.Forms.TextBox).Height


= 100
EndIf
If ctrl.GetType() Is GetType


(System.Windows.Forms.Button) Then
CType(ctrl,System.Windows.Forms.Button).Height =


120
EndIf
Loop
End Sub

Bonne journée

Ghislain Proulx

"Daniel" a écrit


dans le message de
news:923a01c47899$defb0a20$
Je souhaite pouvoir parcourir les objets d'une feuille
WINDOWS
et modifier la hauteur des TEXBOX, des bouttons par
programme, pour obtenir
une hauteur uniforme des champs de saisie, ...
Ci-joint ébauche d'un PGM VB.NET
Comment çà marche ? Merci pour le tuyau !
Daniel




Avatar
Ghislain Proulx
Excuse moi, j'ai tapé ça sans testé et j'ai fais une erreur...

Remplace :
For Each ctrl As Control In FeuilleCourante

Par :
For Each ctrl As Control In FeuilleCourante.Controls

Bonne journée

Ghislain Proulx

a écrit dans le message de
news:96f001c478ac$61b4e690$
Un nouveau message apparaît à l'exécution du code

Expression is of type 'System.Windows.Forms.Form', which
is not a collection type.

Où est l'erreur ?
Daniel


-----Message d'origine-----
Bonjour Daniel,

Sub Remapping()
Dim FeuilleCourante As System.Windows.Forms.Form >System.Windows.Forms.Form.ActiveForm

For Each ctrl As Control In FeuilleCourante
If ctrl.GetType() Is GetType


(System.Windows.Forms.TextBox) Then
CType(ctrl,System.Windows.Forms.TextBox).Height


= 100
EndIf
If ctrl.GetType() Is GetType


(System.Windows.Forms.Button) Then
CType(ctrl,System.Windows.Forms.Button).Height 120
EndIf
Loop
End Sub

Bonne journée

Ghislain Proulx

"Daniel" a écrit


dans le message de
news:923a01c47899$defb0a20$
Je souhaite pouvoir parcourir les objets d'une feuille
WINDOWS
et modifier la hauteur des TEXBOX, des bouttons par
programme, pour obtenir
une hauteur uniforme des champs de saisie, ...
Ci-joint ébauche d'un PGM VB.NET
Comment çà marche ? Merci pour le tuyau !
Daniel