473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

UserControl Woes

Don
I've created a custom UserControlwithin which I have placed a Panel. I've
changed the Panel's "Modifier" property to Public so that it appears in the
Properties Window of the UserControl. This way, I could modify the
properties of the panel within the UserControl when I place a UserControl on
a Form. Or so I thought.

I can set the properties of the Panel within the UserControl via the
Properties Window, but none of the changes made to the Panel inside the
UserControl in this way are remembered when I actually run the project.

Has anyone come across this before? Is there a fix for this?

- Don
Nov 21 '05 #1
3 2143
Hi,

Here is some code from an user control that has a textbox. It has
the user controls textchanged, and validating events fire when the textbox's
events fire. Also makes the user controls text property change the
textboxes text. Hope this helps.

Public Shadows Event TextChanged(ByVal sender As Object, ByVal e As
EventArgs)

Public Shadows Event Validating(ByVal sender As Object, ByRef e As
System.ComponentModel.CancelEventArgs)

Public Shadows Property Text() As String

Get

Return TextBox1.Text

End Get

Set(ByVal Value As String)

TextBox1.Text = Value

End Set

End Property

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

RaiseEvent TextChanged(Me, e)

End Sub

Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating

RaiseEvent Validating(Me, e)

End Sub

Ken

---------------------
"Don" <un*****@oblivion.com> wrote in message
news:1p1pe.1587829$8l.1445249@pd7tw1no...
I've created a custom UserControlwithin which I have placed a Panel. I've
changed the Panel's "Modifier" property to Public so that it appears in the
Properties Window of the UserControl. This way, I could modify the
properties of the panel within the UserControl when I place a UserControl on
a Form. Or so I thought.

I can set the properties of the Panel within the UserControl via the
Properties Window, but none of the changes made to the Panel inside the
UserControl in this way are remembered when I actually run the project.

Has anyone come across this before? Is there a fix for this?

- Don

Nov 21 '05 #2
Don
Thanks for the response, but this doesn't address my issue at all. I would
like to be able to make changes to all controls within a user control in the
Property Designer and have those changes stick when I run the program. I'd
really rather not write all that code for every one of the dozens of
properties for each control. There has to be a way to do that.

- Don
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
Hi,

Here is some code from an user control that has a textbox. It has
the user controls textchanged, and validating events fire when the textbox's events fire. Also makes the user controls text property change the
textboxes text. Hope this helps.

Public Shadows Event TextChanged(ByVal sender As Object, ByVal e As
EventArgs)

Public Shadows Event Validating(ByVal sender As Object, ByRef e As
System.ComponentModel.CancelEventArgs)

Public Shadows Property Text() As String

Get

Return TextBox1.Text

End Get

Set(ByVal Value As String)

TextBox1.Text = Value

End Set

End Property

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

RaiseEvent TextChanged(Me, e)

End Sub

Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating

RaiseEvent Validating(Me, e)

End Sub

Ken

---------------------
"Don" <un*****@oblivion.com> wrote in message
news:1p1pe.1587829$8l.1445249@pd7tw1no...
I've created a custom UserControlwithin which I have placed a Panel. I've
changed the Panel's "Modifier" property to Public so that it appears in the Properties Window of the UserControl. This way, I could modify the
properties of the panel within the UserControl when I place a UserControl on a Form. Or so I thought.

I can set the properties of the Panel within the UserControl via the
Properties Window, but none of the changes made to the Panel inside the
UserControl in this way are remembered when I actually run the project.

Has anyone come across this before? Is there a fix for this?

- Don

Nov 21 '05 #3
Don
I have discovered the solution to my question. If you want to edit
properties for any nested control within a UserControl and not have your
program forget any changes made in the Property Designer window once the
program is executed, you should leave the scope of the control as Friend
(i.e. don't make it Public) and, instead, create a property for it like so:
e.g. Exposing a button called 'Button1' on a UserControl

Imports System.ComponentModel
<DesignerSerializationVisibility(DesignerSerializa tionVisibility.Content)> _
Public ReadOnly Property MyButton() As Button
Get
Return Me.Button1
End Get
End Property
- Don
"Don" <un*****@oblivion.com> wrote in message
news:1p1pe.1587829$8l.1445249@pd7tw1no...
I've created a custom UserControlwithin which I have placed a Panel. I've
changed the Panel's "Modifier" property to Public so that it appears in the Properties Window of the UserControl. This way, I could modify the
properties of the panel within the UserControl when I place a UserControl on a Form. Or so I thought.

I can set the properties of the Panel within the UserControl via the
Properties Window, but none of the changes made to the Panel inside the
UserControl in this way are remembered when I actually run the project.

Has anyone come across this before? Is there a fix for this?

- Don

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Veeneman | last post by:
Is there a simple way to pass drag-and-drop events to a child control in a UserControl? Here's an example: I have created a UserControl which contains a treeview and some text boxes. I want to...
8
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for...
2
by: Eric Maia | last post by:
I have two UserControls I am using in a form. These are each also used separately in two other forms. The structure is essentially this: CourseUserControl.ascx - select or enter a course...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
6
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.