Text Property on Multi- Control User Control

  • Thread starter Thread starter Martin Horner
  • Start date Start date
M

Martin Horner

Hi,

I hope this is the right newsgroup for this question.

I have just created a simple control comprising a third party text editor
(Infragistics) and a couple of button controls. I have attempted to handle
the Text property with the following code:

<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text()
UltraTextEditor1.Text = Value
End Set
End Property

I get the Text property in the Property Pane but I can't get it to persist
the value. It is as if I were failing to maintain a Property bag. If I
change the property name to Display Text and just delegate to
UltraTextEditor1.Text it works fine.

I think that there must be an easy way to do this. Does anyone know what it
is please?
 
Hi Martin,

Here is my demo code using a textbox in a usercontrol.
Imports System.ComponentModel
Public Class UserControl1
Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 96)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'UserControl1
'
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "UserControl1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub
<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text() = Value
End Set
End Property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MsgBox(Me.Text)
End Sub
End Class

You may have a try and let me know if this does the job for you.
Did I misunderstand you meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
 
Hi Peter,

Thanks for the demo code which I have tried. I still find that the Text
Property Value is not persisted when you build a form that the control is
sited on or even if you save a project and reload it. It seems to work
correctly except for the persistence. This is not an immediate problem for
me but I would like to know how to resolve this because I am sure that at
sometime in the future I will want to preset a value in here.

At least I now know the behaviour has nothing to do with the Infragistics
Text Editor.
 
Hi Martin,

What do you mean by "persisted"?
Did you mean that you have create a new project with the code I post, and
built the project, but when you close the project and reload it, and click
the button1 on the usercontol, but the "hello" was not popped up?
[I can not reproduce the problem above.]

Or you mean you want to set text property with button1 and close the
project, then reload the project and click the button2 to get the property?
If so , I think you need to persist the property to the disk before you
close the project and load it back to the property before you click the
button.
Because the property is located in the memory, which will lost its
information after you close the application.

Did I misunderstand your meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
 
Hi Peter,

If you place the new UserControl on a Form and type "Test Value" in the Text
Property in the Property Browser and the saved and unloaded the IDE you
would expect "Test Value". This happens with a standard TextBox or an a
single control that you inherit. What I am finding is that the Text Property
Value is not saved or restored when you close down the IDE. Indeed the value
is lost even when you build the project containing the UserControl.

I don't really want to set any values when the user clicks the button for
the moment I am happy to just raise events. In your example when you
commented out the Me.Text = "hello" in UserControl1_Load I get a blank
message in message box no matter what value I have given to the Text
property at design time.


Peter Huang said:
Hi Martin,

What do you mean by "persisted"?
Did you mean that you have create a new project with the code I post, and
built the project, but when you close the project and reload it, and click
the button1 on the usercontol, but the "hello" was not popped up?
[I can not reproduce the problem above.]

Or you mean you want to set text property with button1 and close the
project, then reload the project and click the button2 to get the property?
If so , I think you need to persist the property to the disk before you
close the project and load it back to the property before you click the
button.
Because the property is located in the memory, which will lost its
information after you close the application.

Did I misunderstand your meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 17:23:30 +1000
Lines: 166
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#mi#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142454
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Thanks for the demo code which I have tried. I still find that the Text
Property Value is not persisted when you build a form that the control is
sited on or even if you save a project and reload it. It seems to work
correctly except for the persistence. This is not an immediate problem for
me but I would like to know how to resolve this because I am sure that at
sometime in the future I will want to preset a value in here.

At least I now know the behaviour has nothing to do with the Infragistics
Text Editor.

e
As what
it
 
Hi Peter,

I thought I had replied yesterday but I don't see the message so I had
better try again.

My problem is saving the Text property value on the new usercontrol either
when the project is saved in the IDE or the project is compiled If I take
this code out of your example

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub

The control always loads with a Text property value of "".


Peter Huang said:
Hi Martin,

What do you mean by "persisted"?
Did you mean that you have create a new project with the code I post, and
built the project, but when you close the project and reload it, and click
the button1 on the usercontol, but the "hello" was not popped up?
[I can not reproduce the problem above.]

Or you mean you want to set text property with button1 and close the
project, then reload the project and click the button2 to get the property?
If so , I think you need to persist the property to the disk before you
close the project and load it back to the property before you click the
button.
Because the property is located in the memory, which will lost its
information after you close the application.

Did I misunderstand your meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 17:23:30 +1000
Lines: 166
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#mi#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142454
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Thanks for the demo code which I have tried. I still find that the Text
Property Value is not persisted when you build a form that the control is
sited on or even if you save a project and reload it. It seems to work
correctly except for the persistence. This is not an immediate problem for
me but I would like to know how to resolve this because I am sure that at
sometime in the future I will want to preset a value in here.

At least I now know the behaviour has nothing to do with the Infragistics
Text Editor.

e
As what
it
 
Hi Martin,

Did you mean you want to persist the property in design time?
You may try to use the DesignerSerializationVisibility attribute.
Here is a sample code. You may have a try.
<Browsable(True),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text = Value
End Set
End Property


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Wed, 1 Oct 2003 10:18:29 +1000
Lines: 239
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142681
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

I thought I had replied yesterday but I don't see the message so I had
better try again.

My problem is saving the Text property value on the new usercontrol either
when the project is saved in the IDE or the project is compiled If I take
this code out of your example

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub

The control always loads with a Text property value of "".


Peter Huang said:
Hi Martin,

What do you mean by "persisted"?
Did you mean that you have create a new project with the code I post, and
built the project, but when you close the project and reload it, and click
the button1 on the usercontol, but the "hello" was not popped up?
[I can not reproduce the problem above.]

Or you mean you want to set text property with button1 and close the
project, then reload the project and click the button2 to get the property?
If so , I think you need to persist the property to the disk before you
close the project and load it back to the property before you click the
button.
Because the property is located in the memory, which will lost its
information after you close the application.

Did I misunderstand your meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 17:23:30 +1000
Lines: 166
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#mi#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142454
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Thanks for the demo code which I have tried. I still find that the Text
Property Value is not persisted when you build a form that the control is
sited on or even if you save a project and reload it. It seems to work
correctly except for the persistence. This is not an immediate problem for
me but I would like to know how to resolve this because I am sure that at
sometime in the future I will want to preset a value in here.

At least I now know the behaviour has nothing to do with the Infragistics
Text Editor.

Hi Martin,

Here is my demo code using a textbox in a usercontrol.
Imports System.ComponentModel
Public Class UserControl1
Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 96)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'UserControl1
'
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "UserControl1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub
<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text() = Value
End Set
End Property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MsgBox(Me.Text)
End Sub
End Class

You may have a try and let me know if this does the job for you.
Did I misunderstand you meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
Subject: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 08:27:03 +1000
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142353
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,

I hope this is the right newsgroup for this question.

I have just created a simple control comprising a third party text editor
(Infragistics) and a couple of button controls. I have attempted to
handle
the Text property with the following code:

<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text()
UltraTextEditor1.Text = Value
End Set
End Property

I get the Text property in the Property Pane but I can't get it to
persist
the value. It is as if I were failing to maintain a Property bag. If I
change the property name to Display Text and just delegate to
UltraTextEditor1.Text it works fine.

I think that there must be an easy way to do this. Does anyone know what
it
is please?
 
Hi Peter,

Yes I did want to persist the value at design time nad your code has
accomplished this. Thank you very much.

Peter Huang said:
Hi Martin,

Did you mean you want to persist the property in design time?
You may try to use the DesignerSerializationVisibility attribute.
Here is a sample code. You may have a try.
<Browsable(True),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text = Value
End Set
End Property


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Wed, 1 Oct 2003 10:18:29 +1000
Lines: 239
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142681
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

I thought I had replied yesterday but I don't see the message so I had
better try again.

My problem is saving the Text property value on the new usercontrol either
when the project is saved in the IDE or the project is compiled If I take
this code out of your example

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub

The control always loads with a Text property value of "".


Peter Huang said:
Hi Martin,

What do you mean by "persisted"?
Did you mean that you have create a new project with the code I post, and
built the project, but when you close the project and reload it, and click
the button1 on the usercontol, but the "hello" was not popped up?
[I can not reproduce the problem above.]

Or you mean you want to set text property with button1 and close the
project, then reload the project and click the button2 to get the property?
If so , I think you need to persist the property to the disk before you
close the project and load it back to the property before you click the
button.
Because the property is located in the memory, which will lost its
information after you close the application.

Did I misunderstand your meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 17:23:30 +1000
Lines: 166
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#mi#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142454
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Thanks for the demo code which I have tried. I still find that the Text
Property Value is not persisted when you build a form that the control is
sited on or even if you save a project and reload it. It seems to work
correctly except for the persistence. This is not an immediate problem for
me but I would like to know how to resolve this because I am sure that at
sometime in the future I will want to preset a value in here.

At least I now know the behaviour has nothing to do with the Infragistics
Text Editor.

Hi Martin,

Here is my demo code using a textbox in a usercontrol.
Imports System.ComponentModel
Public Class UserControl1
Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 96)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'UserControl1
'
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "UserControl1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub UserControl1_Load(ByVal sender As System.Object,
ByVal
e
As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub
<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text() = Value
End Set
End Property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MsgBox(Me.Text)
End Sub
End Class

You may have a try and let me know if this does the job for you.
Did I misunderstand you meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

--------------------
From: "Martin Horner" <[email protected]>
Subject: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 08:27:03 +1000
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au
211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142353
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,

I hope this is the right newsgroup for this question.

I have just created a simple control comprising a third party text
editor
(Infragistics) and a couple of button controls. I have attempted to
handle
the Text property with the following code:

<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text()
UltraTextEditor1.Text = Value
End Set
End Property

I get the Text property in the Property Pane but I can't get it to
persist
the value. It is as if I were failing to maintain a Property bag.
If
 
Hi Martin,

I am glad that you have achieve your aim.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
<[email protected]>
<#mi#[email protected]>
<[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Thu, 2 Oct 2003 14:02:54 +1000
Lines: 310
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:143029
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Yes I did want to persist the value at design time nad your code has
accomplished this. Thank you very much.

Peter Huang said:
Hi Martin,

Did you mean you want to persist the property in design time?
You may try to use the DesignerSerializationVisibility attribute.
Here is a sample code. You may have a try.
<Browsable(True),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text = Value
End Set
End Property


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Wed, 1 Oct 2003 10:18:29 +1000
Lines: 239
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142681
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

I thought I had replied yesterday but I don't see the message so I had
better try again.

My problem is saving the Text property value on the new usercontrol either
when the project is saved in the IDE or the project is compiled If I take
this code out of your example

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub

The control always loads with a Text property value of "".


Hi Martin,

What do you mean by "persisted"?
Did you mean that you have create a new project with the code I post, and
built the project, but when you close the project and reload it, and click
the button1 on the usercontol, but the "hello" was not popped up?
[I can not reproduce the problem above.]

Or you mean you want to set text property with button1 and close the
project, then reload the project and click the button2 to get the
property?
If so , I think you need to persist the property to the disk before you
close the project and load it back to the property before you click the
button.
Because the property is located in the memory, which will lost its
information after you close the application.

Did I misunderstand your meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Martin Horner" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 17:23:30 +1000
Lines: 166
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#mi#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au 211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142454
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Thanks for the demo code which I have tried. I still find that the Text
Property Value is not persisted when you build a form that the
control
is
sited on or even if you save a project and reload it. It seems to work
correctly except for the persistence. This is not an immediate problem
for
me but I would like to know how to resolve this because I am sure
that
at
sometime in the future I will want to preset a value in here.

At least I now know the behaviour has nothing to do with the Infragistics
Text Editor.

Hi Martin,

Here is my demo code using a textbox in a usercontrol.
Imports System.ComponentModel
Public Class UserControl1
Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 96)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'UserControl1
'
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "UserControl1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles MyBase.Load
Me.Text = "hello"
End Sub
<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
MyBase.Text() = Value
End Set
End Property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles Button1.Click
MsgBox(Me.Text)
End Sub
End Class

You may have a try and let me know if this does the job for you.
Did I misunderstand you meaning?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

--------------------
From: "Martin Horner" <[email protected]>
Subject: Text Property on Multi- Control User Control
Date: Tue, 30 Sep 2003 08:27:03 +1000
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: c211-28-48-12.eburwd1.vic.optusnet.com.au
211.28.48.12
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142353
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,

I hope this is the right newsgroup for this question.

I have just created a simple control comprising a third party text
editor
(Infragistics) and a couple of button controls. I have attempted to
handle
the Text property with the following code:

<Browsable(True)> _
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text()
UltraTextEditor1.Text = Value
End Set
End Property

I get the Text property in the Property Pane but I can't get it to
persist
the value. It is as if I were failing to maintain a Property bag.
If
I
change the property name to Display Text and just delegate to
UltraTextEditor1.Text it works fine.

I think that there must be an easy way to do this. Does anyone know
what
it
is please?
 
Back
Top