Quote:
Originally posted by wanhobi
here is the code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text = PropBag.ReadProperty("Text", "")
Midpoint = PropBag.ReadProperty("Midpoint", 1330)
UserControl.Width = PropBag.ReadProperty("Width", 4800)
Caption = PropBag.ReadProperty("Caption", "Caption")
DataFormat = PropBag.ReadProperty("DataFormat", "")
UserControl_Resize
txtTextBox_LostFocus
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Text", txtTextBox.Text
PropBag.WriteProperty "Midpoint", Midpoint
PropBag.WriteProperty "Width", UserControl.Width
PropBag.WriteProperty "Caption", Caption
PropBag.WriteProperty "DataFormat", msDataFormat
'PropBag.WriteProperty "MaxLength", txtTextBox.MaxLength
UserControl_Resize
txtTextBox_LostFocus
End Sub
Private Sub UserControl_Resize()
Dim lLeft As Long
UserControl.Height = txtTextBox.Height
txtTextBox.Width = UserControl.Width - txtTextBox.Left
End Sub
Public Property Get Midpoint() As Long
Midpoint = txtTextBox.Left
End Property
Public Property Let Midpoint(lTwips As Long)
txtTextBox.Left = lTwips
UserControl_Resize
End Property
Public Property Get TextWidth() As Long
TextWidth = txtTextBox.Width
End Property
Public Property Let TextWidth(lTwips As Long)
txtTextBox.Width = lTwips
End Property
Public Property Get Text() As String
Text = txtTextBox.Text
End Property
Public Property Let Text(sText As String)
If msDataFormat > "" Then
txtTextBox.Text = Format$(sText, msDataFormat)
Else
txtTextBox.Text = sText
End If
End Property
Public Property Get Caption() As String
Caption = lblLabel.Caption
End Property
Public Property Let Caption(sText As String)
lblLabel.Caption = sText
End Property
Public Property Get Enabled() As Boolean
Enabled = txtTextBox.Enabled
End Property
Public Property Let Enabled(bEnabled As Boolean)
txtTextBox.Enabled = bEnabled
txtTextBox.BackColor = IIf(bEnabled, vbWhite, RGB(220, 220, 220))
End Property
Public Property Get DataFormat() As String
DataFormat = msDataFormat
End Property
Public Property Let DataFormat(sValue As String)
msDataFormat = sValue
End Property
Beat you to it. :p