|
-
Jan 11th, 2004, 05:20 AM
#1
Thread Starter
Lively Member
Overriding Custom UserControl Text Property
Why am I having so much doing this? I'm trying to override the default UserControl classes Text property, but I can't get it to show in design view properties. Here is my code, I'm sure someone has ran into this before.
VB Code:
Public Overrides Property Text() As String
Get
Text = Me.Text
End Get
Set(ByVal Value As String)
Me.Text = Value
Me.Invalidate()
End Set
End Property
-
Jan 12th, 2004, 05:46 AM
#2
Is this any help?
VB Code:
<System.ComponentModel.Localizable(True)>Public Overrides Property Text() As String
'Your code.
End Property
This world is not my home. I'm just passing through.
-
Jan 12th, 2004, 10:58 AM
#3
Ive had a look and couldnt work it out either, hmmmm.
If you just want to set the default value, you can do it by code (thats all it does anyway), in your form declaration (eg)
VB Code:
'UserControl11
'
Me.UserControl11.Location = New System.Drawing.Point(184, 168)
Me.UserControl11.Name = "UserControl11"
Me.UserControl11.Size = New System.Drawing.Size(232, 120)
Me.UserControl11.TabIndex = 3
Me.UserControl11.Text = "This data"
Id be interested in the result.
-
Jan 12th, 2004, 10:59 AM
#4
I forgot to add, you probly need to change your code to something like this, your not calling your base control.text property.
VB Code:
Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text = Value
Me.Invalidate()
End Set
End Property
-
Jan 12th, 2004, 12:01 PM
#5
Sleep mode
Why are you using Me.Invalidate() method , it means nothing if you're not doing any drawing stuff . I know this has nothing to do with the problem rather it's aside note .
-
Jan 12th, 2004, 02:13 PM
#6
Thread Starter
Lively Member
I am doing to Me.Invalidate because I am drawing my own custom button. I also draw my own text, so I really need to have the text property visible.
-
Jan 12th, 2004, 06:56 PM
#7
Sleep mode
Originally posted by D.Viddy
I am doing to Me.Invalidate because I am drawing my own custom button. I also draw my own text, so I really need to have the text property visible.
I know but it doesn't make sense here (to me at least since in this method I can't see any drawing stuff ) . Anyway , Did you try this ? (though this is what I do in all my custom controls and it works).
VB Code:
Private mText As String
Public Overrides Property Text() As String
Get
Return mText
End Get
Set(ByVal Value As String)
mText = Value
End Set
End Property
-
Jan 12th, 2004, 09:05 PM
#8
Thread Starter
Lively Member
Uhhh yeah it does make sense, because if the user changes the text the control will need to be redrawn to reflect the changes.
-
Jan 12th, 2004, 11:33 PM
#9
Thread Starter
Lively Member
None of this is working, hasn't anyone every made their own usercontrol and had the text property not show up in design time???
-
Jan 12th, 2004, 11:48 PM
#10
Did you try adding the Browsable attribute?
VB Code:
[b]<Browsable(True)> _[/b]
Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text = Value
Me.Invalidate()
End Set
End Property
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|