|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ShouldSerialize problem in inherited controlI'm using VB.NET 2003 and designing a custom control which inherits from TextBox. In this inherited control, I would like to reassign default value of some properties, such as BorderStyle. I found that it is impossible to change default value using ShouldSerialize and Reset pair in design form which consume my custom control. My custom control is in attachement. I have changed the default value of BorderStyle to FixedSingle in custom control. However, in design form, the default value is still Fixed3D if I click Reset on BorderStyle in property panel. How can I solve this problem? Thanks for your attention and kindly help! Regards, James Wong [attached file: ctrTestBox.vb] Don't use ShouldSerialize and Reset. See example below:
Option Explicit On Option Strict On Imports System.ComponentModel Public Class MyNewText Inherits System.Windows.Forms.TextBox Public Sub New() MyBase.New() MyBase.BorderStyle = BorderStyle.FixedSingle End Sub <DefaultValue(GetType(BorderStyle), "FixedSingle")> _ Public Shadows Property BorderStyle() As BorderStyle Get Return MyBase.BorderStyle End Get Set(ByVal Value As BorderStyle) MyBase.BorderStyle = Value End Set End Property End Class Show quoteHide quote "James Wong" <cphk_msdn@nospam.nospam> wrote in message news:uUoNPvjGGHA.2708@TK2MSFTNGP11.phx.gbl... > Dear all, > > I'm using VB.NET 2003 and designing a custom control which inherits from > TextBox. In this inherited control, I would like to reassign default > value of some > properties, such as BorderStyle. I found that it is impossible to change > default value using ShouldSerialize and Reset pair in design form which > consume my custom control. > > My custom control is in attachement. I have changed the default value of > BorderStyle to FixedSingle in custom control. However, in design form, > the > default value is still Fixed3D if I click Reset on BorderStyle in property > panel. How can I solve this problem? > > Thanks for your attention and kindly help! > > Regards, > James Wong > > > Hi Rocky,
It works! Thanks a lot! James Show quoteHide quote "Rocky" <nopl***@nowhere.com> ¼¶¼g©ó¶l¥ó·s»D:uOUfXKlGGHA.1***@TK2MSFTNGP09.phx.gbl... > Don't use ShouldSerialize and Reset. See example below: > > Option Explicit On > Option Strict On > Imports System.ComponentModel > > Public Class MyNewText > Inherits System.Windows.Forms.TextBox > > Public Sub New() > MyBase.New() > MyBase.BorderStyle = BorderStyle.FixedSingle > End Sub > > <DefaultValue(GetType(BorderStyle), "FixedSingle")> _ > Public Shadows Property BorderStyle() As BorderStyle > Get > Return MyBase.BorderStyle > End Get > Set(ByVal Value As BorderStyle) > MyBase.BorderStyle = Value > End Set > End Property > > End Class > > > > > > > > "James Wong" <cphk_msdn@nospam.nospam> wrote in message > news:uUoNPvjGGHA.2708@TK2MSFTNGP11.phx.gbl... >> Dear all, >> >> I'm using VB.NET 2003 and designing a custom control which inherits from >> TextBox. In this inherited control, I would like to reassign default >> value of some >> properties, such as BorderStyle. I found that it is impossible to change >> default value using ShouldSerialize and Reset pair in design form which >> consume my custom control. >> >> My custom control is in attachement. I have changed the default value of >> BorderStyle to FixedSingle in custom control. However, in design form, >> the >> default value is still Fixed3D if I click Reset on BorderStyle in >> property panel. How can I solve this problem? >> >> Thanks for your attention and kindly help! >> >> Regards, >> James Wong >> >> >> > >
VB for .NET Recommended?
They do this in C# can't we do it in VB?? C DLL Callback to VB.NET 2005 Which database should I use? vbexpress and sql2000 Checking a string for filename compliance Moving a drawing Crystal Report parameter dialog box Formatting the ComboBox editing window help !!!! databinding with text box |
|||||||||||||||||||||||