473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl Woes

Don
I've created a custom UserControlwith in 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 2150
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(ByV al sender As Object, ByVal e As
EventArgs)

Public Shadows Event Validating(ByVa l sender As Object, ByRef e As
System.Componen tModel.CancelEv entArgs)

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_TextCh anged(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles TextBox1.TextCh anged

RaiseEvent TextChanged(Me, e)

End Sub

Private Sub TextBox1_Valida ting(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles TextBox1.Valida ting

RaiseEvent Validating(Me, e)

End Sub

Ken

---------------------
"Don" <un*****@oblivi on.com> wrote in message
news:1p1pe.1587 829$8l.1445249@ pd7tw1no...
I've created a custom UserControlwith in 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***@bellsout h.net> wrote in message
news:u%******** ********@TK2MSF TNGP10.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(ByV al sender As Object, ByVal e As
EventArgs)

Public Shadows Event Validating(ByVa l sender As Object, ByRef e As
System.Componen tModel.CancelEv entArgs)

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_TextCh anged(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles TextBox1.TextCh anged

RaiseEvent TextChanged(Me, e)

End Sub

Private Sub TextBox1_Valida ting(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles TextBox1.Valida ting

RaiseEvent Validating(Me, e)

End Sub

Ken

---------------------
"Don" <un*****@oblivi on.com> wrote in message
news:1p1pe.1587 829$8l.1445249@ pd7tw1no...
I've created a custom UserControlwith in 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.Componen tModel
<DesignerSerial izationVisibili ty(DesignerSeri alizationVisibi lity.Content)> _
Public ReadOnly Property MyButton() As Button
Get
Return Me.Button1
End Get
End Property
- Don
"Don" <un*****@oblivi on.com> wrote in message
news:1p1pe.1587 829$8l.1445249@ pd7tw1no...
I've created a custom UserControlwith in 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
7109
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 be able to drag-and-drop to the treeview from outside the UserControl. Now, when I drag over the treeview in the UserControl, the UserControl gets...
8
1950
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 that category, the results are paged 10 to a page and the user can page them. As this "Category" usercontrol hardly ever changes I wanted to setup...
2
2235
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 SessionUserControl.ascx - select or enter a course session CourseDetails.aspx - a form which contains just CourseUserControl CourseSessionDetails.aspx -...
2
4607
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 for me! I apologize for the length of this posting, but I wanted to make sure that I get an answer other than "Hey man, just use LoadControl!",...
41
4256
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 on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. ...
12
2183
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 server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places...
9
14425
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 does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same...
6
12123
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 binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is...
10
2404
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 my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from...
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7808
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7423
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.