473,386 Members | 1,924 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,386 software developers and data experts.

Custom UserControl with subcontrols (designer support)

Hello,

i tried to compose myself a custom usercontrol which is derieved from
System.Windows.Forms.UserControl.

It contains 2 comboboxes and one textbox (which are also custom
controls,
but directly derived from the .net classes ComboBox and TextBox)

I did the custom control in the visual studio .net designer in which i
aligned the
controls inside properly, set the anchors and the other layout things.

As i compiled it and dropped in onto a new form i cannot select any of
the components (i.e. the comboboxes) inside the control.

I wanted to use the control in such a way that i can select the
subcontrols inside the control and adjust the settings for each one
individually in the propertygrid.

How can i do this?

I tried to overwrite the Control.Controls Method but that did not
work.
And i read its not that easy because one overwrites the serializer and
that must be handled properly.

(i know that has something to do with design-time support, but i dont
understand it properly)

but with the control-subcontrol property i should not go into deph
with design time programming.
or am i wrong?

could anyone tell me what to do to make the subcontrols available in
the designer (i.e. which methods to overwrite ?)

and where can i find resources or books about design time programming
besides the msdn-documentation?

thanks

Martin
Nov 15 '05 #1
7 12474
Hello Martin,

The contained controls are declared private in the user control code by
default. This effectively prevents them to be modified when your user
control is placed onto a form in the designer. You should declare them as
public if you want the control's clients to be able to modify their
properties.

To do that, open your user control in the designer, select all the controls
and change their Modifiers property value to "Public" in the Property
Browser.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Martin Schulze" <ma******@tiscali.de> wrote in message
news:69**************************@posting.google.c om...
Hello,

i tried to compose myself a custom usercontrol which is derieved from
System.Windows.Forms.UserControl.

It contains 2 comboboxes and one textbox (which are also custom
controls,
but directly derived from the .net classes ComboBox and TextBox)

I did the custom control in the visual studio .net designer in which i
aligned the
controls inside properly, set the anchors and the other layout things.

As i compiled it and dropped in onto a new form i cannot select any of
the components (i.e. the comboboxes) inside the control.

I wanted to use the control in such a way that i can select the
subcontrols inside the control and adjust the settings for each one
individually in the propertygrid.

How can i do this?

I tried to overwrite the Control.Controls Method but that did not
work.
And i read its not that easy because one overwrites the serializer and
that must be handled properly.

(i know that has something to do with design-time support, but i dont
understand it properly)

but with the control-subcontrol property i should not go into deph
with design time programming.
or am i wrong?

could anyone tell me what to do to make the subcontrols available in
the designer (i.e. which methods to overwrite ?)

and where can i find resources or books about design time programming
besides the msdn-documentation?

thanks

Martin


Nov 15 '05 #2
> Hello Martin,

The contained controls are declared private in the user control code by
default. This effectively prevents them to be modified when your user
control is placed onto a form in the designer. You should declare them as
public if you want the control's clients to be able to modify their
properties.

To do that, open your user control in the designer, select all the controls
and change their Modifiers property value to "Public" in the Property
Browser.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE


Hello,

i did that but that had no effect in the designer window.

i wanted to click onto the subcontrol in the control and modify its
properties.

but meanwhile i found a solution in an example found in the internet.
It has a control collection and is done by a custom designer and a
custom type-converter.

thanks a lot
Martin
Nov 15 '05 #3
I have a similar problem - UserControl composite control, one of sub controls is a listView. I had delegated Columns property of my composite control to the listView's Column property hoping that the designer would be able to add/configure column headers for my listView. It kind of works but the designer obviously does not know that it needs to generate code to add column headers to my list view. The code that usually looks like this:

lView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2, this.columnHeader3});

is missing.

Does the example you found on the net cover designer support for user controls (especially code generation aspects)? I would appreciate URL or any clues on the subject
Regards
bk
----- Martin Schulze wrote: -----
Hello Martin,
The contained controls are declared private in the user control code by

default. This effectively prevents them to be modified when your user
control is placed onto a form in the designer. You should declare them as
public if you want the control's clients to be able to modify their
properties.
To do that, open your user control in the designer, select all the controls

and change their Modifiers property value to "Public" in the Property
Browser.
--

Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE


Hello,

i did that but that had no effect in the designer window.

i wanted to click onto the subcontrol in the control and modify its
properties.

but meanwhile i found a solution in an example found in the internet.
It has a control collection and is done by a custom designer and a
custom type-converter.

thanks a lot
Martin

Nov 15 '05 #4
Hi,

You should specify the same UIEditor for the property you use to expose the
columns collection as is used for the original Columns property. Still, I am
not sure code generation will work seamlessly - I am just not that
experienced in advanced design-time support for UI controls.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"BorisDotNet" <an*******@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I have a similar problem - UserControl composite control, one of sub controls is a listView. I had delegated Columns property of my composite
control to the listView's Column property hoping that the designer would be
able to add/configure column headers for my listView. It kind of works but
the designer obviously does not know that it needs to generate code to add
column headers to my list view. The code that usually looks like this:
lView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2, this.columnHeader3});

is missing.

Does the example you found on the net cover designer support for user controls (especially code generation aspects)? I would appreciate URL or any
clues on the subject Regards
bk
----- Martin Schulze wrote: -----
> Hello Martin,
>> The contained controls are declared private in the user control
code by > default. This effectively prevents them to be modified when your user > control is placed onto a form in the designer. You should declare them as > public if you want the control's clients to be able to modify their
> properties.
>> To do that, open your user control in the designer, select all the
controls > and change their Modifiers property value to "Public" in the Property > Browser.
>> --

> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
> http://www.x-unity.net/teststudio.aspx
> Bring the power of unit testing to VS .NET IDE


Hello,

i did that but that had no effect in the designer window.

i wanted to click onto the subcontrol in the control and modify its
properties.

but meanwhile i found a solution in an example found in the internet.
It has a control collection and is done by a custom designer and a
custom type-converter.

thanks a lot
Martin


Nov 15 '05 #5
Arrggg - Martin, I'm trying to do this also - where'd you find the aricle on the web
Could you post it here please
This is making me crazy, it should be far, far simpler than this... :

----- Martin Schulze wrote: ----
Hello Martin
The contained controls are declared private in the user control code b

default. This effectively prevents them to be modified when your use
control is placed onto a form in the designer. You should declare them a
public if you want the control's clients to be able to modify thei
properties
To do that, open your user control in the designer, select all the control

and change their Modifiers property value to "Public" in the Propert
Browser
--

Dmitriy Lapshin [C# / .NET MVP
X-Unity Test Studi
http://www.x-unity.net/teststudio.asp
Bring the power of unit testing to VS .NET ID


Hello

i did that but that had no effect in the designer window

i wanted to click onto the subcontrol in the control and modify it
properties

but meanwhile i found a solution in an example found in the internet
It has a control collection and is done by a custom designer and
custom type-converter

thanks a lot
Marti

Nov 15 '05 #6
I'm not too sure about that. Default UIEditor for the collections is the Collection Editor. This editor is used for ListView and this is the editor I’m happy with. More to it, this editor is invoked by the designer, i can add/remove/modify column headers no problems, the code is generated to declare and to instantiate collection items but the code to add them to the collection is not there.
Nov 15 '05 #7
I found the answer. All I had to do was to adorn my Columns property (the one of the collection type) with appropriate Property Browser attribute

DesignerSerializationVisibilityAttribute(DesignerS erializationVisibility.Content

public ListView.ColumnHeaderCollection Column

ge

..

This attribute causes the Designer to serialize (generate) code to add collection items to the collection.
Fortunately for me the collection items are of known type (ListView ColumnHeaders) so I did not have to write Type Converter, UI Editor, etc

The answer was found in Chris Sells Windows Form Programming in C# that now worth it's weight in gold for me
Thanks Chris
Nov 15 '05 #8

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

Similar topics

2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
2
by: Robbie | last post by:
I have a Web Form with some tailored logos and artwork. The web form also has a user control that has typical registration info on it (Name, Company Name, etc.) One of the fields, a TextBox, is a...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
2
by: Rene Sørensen | last post by:
In VS 2005 I'm trying to create a usercontrol, but I have some problems with it right now I can't figure out how to fix. The size of my usercontrol is "Size 574; 619" I have anchored all controls...
5
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.