Je voudrais créer un UserControl avec plusieurs propriétés.
Je vais en prendre une seule pour vous expliquer mon problème.
Mon UserControl n'est composé que d'un seul TextBox pour lequel je veux une propriété BackColor. Pas de problème pour créer la propriété, le controle.
Ensuite lorsque je suis en mode création, je place sur une form mon UserControl je vais dans la fenêtre propriétés, je change de couleur de fond et j'ai bien la couleur sélectionnée. Par contre lorsque je lance le prog je n'ai pas la couleur voulue?? Si je reviens en mode création j'ai pourtant bien la couleur voulue dans la page de propriété???
Voici mon code et merci pour vos réponses (je ne comprends plus rien!!)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Option Explicit '-- Propriétés par défaut Private Const m_def_BackColor As Long = &HFFFFFF '-- Variables : Property. Lues à partir du property bag Dim m_BackColor As OLE_COLOR Private Sub UserControl_Initialize() m_BackColor = m_def_BackColor End Sub Private Sub UserControl_Resize() Text1.Move 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight End Sub Public Property Get BackColor() As OLE_COLOR BackColor = m_BackColor End Property Public Property Let BackColor(ByVal NewBackColor As OLE_COLOR) m_BackColor = NewBackColor Text1.BackColor = m_BackColor PropertyChanged "BackColor" End Property Private Sub UserControl_ReadProperties(PropBag As PropertyBag) m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor) End Sub Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor) End Sub
Partager