Les Snippets

Connexion

DONNER UNE VALEUR DANS L'ENSEMBLE D'UN MÊME TYPE DE CONTROLE

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 30/12/2007 16:14:13 et initié par us_30 [Liste]
Vue : 2975
Catégorie(s) : Trucs & Astuces, Control, UserControl
Langages dispo pour ce code :
- VBA
- VB6



Langage : VBA
Date ajout : 30/12/2007
Posté par us_30 [Liste]
Property Let TypeControl(oObjet As Object, NameControl As String, _
            NamePropriete As String, ValuePropriete As Variant)
' DONNE UNE VALEUR A UNE PROPRIETE A L'ENSEMBLE D'UN TYPE DE CONTROLE
Dim cTypeControl As Control
For Each cTypeControl In oObjet.Controls
    If StrComp(TypeName(cTypeControl), NameControl, vbTextCompare) = 0 Then
        CallByName cTypeControl, NamePropriete, VbLet, ValuePropriete 
    End If
Next
Set cTypeControl = Nothing
End Property

' TEST ' ' Mettre une Frame (frame1) dans une userform (UserForm1) ' Remplir la Frame et l'UserForm avec des checkbox et textbox ' Mettre 2 boutons Private Sub CommandButton1_Click() 'Seules les éléments de Userform1.Frame1 sont concernés '(on pourrait aussi écrire Me.Frame1 si Me = Userform1) 'Coche toutes les checkbox TypeControl(UserForm1.Frame1, "checkbox", "value") = 1 'Rempli toutes les textbox TypeControl(UserForm1.Frame1, "textbox", "text") = "Frame1" End Sub Private Sub CommandButton2_Click() ' Me = toute la Userform1 'Vide les checkbox et les textbox TypeControl(Me, "checkbox", "value") = 0 TypeControl(Me, "textbox", "text") = vbNullString End Sub
Remarque :
TypeControl peut s'appliquer à tous les contrôles contenus dans une Userform chargée ou non.
Langage : VB6
Date ajout : 01/01/2008
Posté par us_30 [Liste]
Property Let TypeControl(oObjet As Object, NameContainer As String, NameControl As String, _ 
            NamePropriete As String, ValuePropriete As Variant) 
' DONNE UNE VALEUR A UNE PROPRIETE A L'ENSEMBLE D'UN TYPE DE CONTROLE 
 
Dim cTypeControl As Control 
 
For Each cTypeControl In oObjet.Controls 
    If StrComp(TypeName(cTypeControl), NameControl, vbTextCompare) = 0 Then 
        If NameContainer = vbNullString Then 
            CallByName cTypeControl, NamePropriete, VbLet, ValuePropriete 
        Else 
            On Error Resume Next 
            If StrComp(cTypeControl.Container, NameContainer, vbTextCompare) = 0 Then 
                If Err = 0 Then CallByName cTypeControl, NamePropriete, VbLet, ValuePropriete 
            End If 
        End If 
    End If 
Next 
 
Set cTypeControl = Nothing 
 
End Property
Remarque :
pour l'utiliser :
TypeControl(Me, vbNullString, "picturebox", "picture") = Nothing
TypeControl(Me, "", "checkbox", "value") = 0
TypeControl(Me, "Frame1", "Textbox", "Text") = vbNullString

On mettra vbnullstring ou "", pour que tous les contrôles de la feuille soient modifiés. On indiquera le "Conteneur", (Frame1), pour modifier que ceux contenus dans ce dernier.

Snippets en rapport avec : Control, Valeurs



Codes sources en rapport avec : Control, Valeurs

{Visual Basic, VB6, VB.NET, VB 2005} LABEL ET IMAGE DANS TEXTBOX
une petite classe qui améliore la TextBox on ajoute un background label et une background picture ...

{Visual Basic, VB6, VB.NET, VB 2005} SCROLL USER CONTROL
L'exemple d'utilisation de ce Contrôle user permet de Transformer le Bureau en pupitre de jeu Online...

{Visual Basic, VB6, VB.NET, VB 2005} CONTROLE IMAGE ZOOM/DÉZOOM
Un petit control permettant de zoomer / dézoomer ainsi que de déplacer l'image, le tout à la souris....

{C# / C#.NET} LIBRAIRIE TRÈS COMPLETTE DE CONTROLS WINFORMS PERSONNALISÉS
Voici la dernière monture de ma librairie winform. Celle-ci contient une bonne trentaines de control...

{Visual Basic, VB6, VB.NET, VB 2005} JEU DE DAMES UNIVERSEL EN SOLITAIRE
Evolution de ma précédente source "jeu de dames américain". http://www.vbfrance.com/codes/JEU-DAMES-...

{Visual Basic, VB6, VB.NET, VB 2005} MOUSEOUT ET MOUSEOVER SUR LES CONTROLES WINDOWLESS TRANSPARENTS
control windowless qui permet de prendre en charge les evenement mouseout et mouseover je me suis...

{Visual Basic, VB6, VB.NET, VB 2005} CONTROLE UTILISATEUR COLORPICKER FAÇON PHOTOSHOP
Un contrôle utilisateur pour sélectionner une couleur, de la même façon que Photoshop. (voir capture...

{Visual Basic, VB6, VB.NET, VB 2005} PROGRESSBAR
c'est un petit programme pour débutants,il s'agit d'une progressbar et d'un controle animation.la pr...

{Visual Basic, VB6, VB.NET, VB 2005} NOUVEAU CONTRÔLE DYNAMICDATAGRIDVIEW
Ce contrôle est un interface sert a faire un mis a jour a une base de données Donc ce contrôle va s...

{Visual Basic, VB6, VB.NET, VB 2005} XPLISTVIEW
Il s'agit là d'un portage d'une source C# en VB.Net Voici donc une ListView améliorée : - Pos...