Why is no one answering my post I need urgent help please? Using a Windows Forms Control as a Contai

N

Neo

Hi,

I have a Windows Forms app written in vb.NET. I have 2 controls and a form
in the solution, one control (say control1) is used in another control (say
control2) and control2 is placed on a form. I am aware of how to make
control2 a container so that other controls can be placed on it in the IDE
(code below).

I would like to know how I can make control1 the container, so when control2
is placed on a form and a control is added to it, the control is added to
the container being control1 not control2. (hope this makes sense!)

I have tried making control1 a container and this hasn't worked, also I have
tried making control2 the container and when a control is added catching the
event and trying to add the control that was placed on control2 to control1
through code and there are issues there to.

I have seen several controls that must have to do this in some way.

Control2 currently has the following attribute and imports to make the IDE
aware this is a container:

Imports System.ComponentModel
Imports System.ComponentModel.Design
<DesignerAttribute(GetType(System.windows.forms.design.ParentControlDesigner
))> _

and then override the OnControlAdded event and add the following to bring
the added control to the front:
MyBase.OnControlAdded(e)
e.Control.BringToFront()

Any help is great, thanks.
 
G

Guest

I guess that it is not very clear what you are trying to accomplish here...Let me see if i understand

You have a user control Control1 that has another user control Control2 on it. Let's say control 1 is a panel and control 2 is a treeview. You then place your control1 (the panel) on a form. Then, when you add (by using drag and drop) another control to the control1 (the panel) you want that control added to the control2 (the treeview) rather than the control1 as it is by default? Basically you want your control1 to behave like a GroupBox?

Is this what you need
 
M

Manfred Gloiber

Hi Neo,

If you don't want to wait for answers go away and hire a consultant and/or a
professional!!! Answering questions and helping poeple here isn't a paid
job, most poeple here do it in there spare time and simply because they like
it to help others so shut the f*ck up and get real! Nobody is responsible
for you except yourself!

Bye
- Manfred
 
P

padawan

Too True.
Sorry this post may have sounded a little 'snarky', I was just not clear if
no-one understood my question or what?, so apologies.
 
P

padawan

(This has been posted this at windowsforms.controls)

Sorry this post may have sounded a little 'snarky', someone commented on
this in another thread, I was just not clear if no-one understood my
question
or what?, so apologies.

Yes you are exactly right, I have read lots of articles, posts, forums and
MS Documentation, still nothing that answers my question directly. I believe
this is just a matter of finding the right designer attribute, as this line
applied to the control class:
<DesignerAttribute(GetType(System.windows.forms.design.ParentControlDesigner
))> _
will make the control a container when placed on a form.

I am basically creating an outlook style menu control, although it will not
look the same and have alot more flexibility than others I have found.

The main control is 'XMBar' which is basically just a container for the
'XMBPages' which are the menu items for the control. At design time the
'Pages' property will represent the collection of 'XMBPages' which will be
added dynamically. Each 'XMBPage' will be a container for other controls to
be added from the toolbox.

I have found some source, but it is all in C# and I use vb, although I can
decifer it some things don't make sense.

Thanks for your reply.

Iulian Ionescu said:
I guess that it is not very clear what you are trying to accomplish
here...Let me see if i understand:
You have a user control Control1 that has another user control Control2 on
it. Let's say control 1 is a panel and control 2 is a treeview. You then
place your control1 (the panel) on a form. Then, when you add (by using drag
and drop) another control to the control1 (the panel) you want that control
added to the control2 (the treeview) rather than the control1 as it is by
default? Basically you want your control1 to behave like a GroupBox?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top