473,769 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl and containing controls problem...

Hi,
I'm making my own control which holds some buttons ant textboxes and also
has a panel control.
in design time i want to drop another controls into the panel that is in my
usercontrol.

the problem is that the added controls are added to the usercontrol and not
to the panel...

10X,

Nov 21 '05 #1
7 3802
On 20/10/2004 Alon wrote:
Hi,
I'm making my own control which holds some buttons ant textboxes and
also has a panel control.
in design time i want to drop another controls into the panel that is
in my usercontrol.

the problem is that the added controls are added to the usercontrol
and not to the panel...

10X,


Alon

I asked a similar question some time ago and from the response it seems
this is not possible, you can't use drag and drop to add other controls
to a user control at design time.

I'm surprised that you have achieved the success you have, are you sure
the control you are adding is being added to your user control? Does it
move around when you move the user control or is it left behind?

--
Jeff Gaines Damerham Hampshire UK
Nov 21 '05 #2
You can expose the Panel on the hosted container (form) where the
UserControl is also created. If it is also a component being designed, you
can just drag controls into it and the said controls will be added in its
(Panel's) Controls Collection. The only trick is how and when to create the
panel component using the IDesignerHost.C reateComponent method so it will be
designable and then add it to the Controls collection of the UserControl. I
believe one can do this on the Initialize method of the control's designer
class when a control is dragged onto the form and the designer is being
initialized for the dragged control/component.
"Alon" <Al**@discussio ns.microsoft.co m> wrote in message
news:CA******** *************** ***********@mic rosoft.com...
Hi,
I'm making my own control which holds some buttons ant textboxes and also
has a panel control.
in design time i want to drop another controls into the panel that is in my usercontrol.

the problem is that the added controls are added to the usercontrol and not to the panel...

10X,

Nov 21 '05 #3
Jeff - yes. when i relocate my usercontrol (at runtime or design) the
controls i added to it are attached .
Joey - it sounds rather complicated. and im not sure it's possible (although
i didnt try)
as a solution i can always do it all as a component which inherit a panel
and so on... i think it should work but needs a lot more background work
without inheriting the usercontrol...

it's pity the usercontrol is so poor, rather nice potential.

by the way, does anyone knows the design attributes that can help me decides
which controls the user can add on design time to a container (ie panel) and
which he cant ?
thanks.
Nov 21 '05 #4
Joey - it sounds rather complicated. and im not sure it's possible (although i didnt try)
as a solution i can always do it all as a component which inherit a panel
and so on... i think it should work but needs a lot more background work
without inheriting the usercontrol...

I was able to replicate the .NET TabControl with buttons to click on and
panels as detail where user can drag controls into. Btw: WinForm controls
including panel is already a component. The idea is to create the control
from IDesignerHost so it is present on the container surface at design time.
http://www.divil.co.uk/net/articles/...oncontrols.asp
by the way, does anyone knows the design attributes that can help me decides which controls the user can add on design time to a container (ie panel) and which he cant ?


You should attach a custom designer to your custom panel control inheriting
from ParentControlDe signer and then override the CanParent method...

Nov 21 '05 #5
hi,
10X for the "CanParent" tip, i solved it through overriding the
"OnControlAdded " method. which is better way to do it ?

and regarding my base problem, i kind of got to the next phase - i now have
a usercontrol of type "A" who can hold lots of usercontrols of type "B". if
i drag the "A" and then drag the "B" into "A" i CAN add other controls to
"B". that was my initial meaning !!!
BUT, while this situation is ok, i rather want "A" to have a collection
property of "B"s (like tabcontrol with tabpages etc) with all "B"'s
properties.
this cause me 2 problems:
1) i understood i need a collection class and an item class and lots of
other stuff. is there a good article/code example anywhere about it ? couldnt
find any that is really thorough... (Joey - i already saw the article you
attached, 10X a lot but this example do not really take care all the aspects
i need, although when read it, i started to understand what is waiting for
me....:))
2) i kind of succeeded in doing something like a collection (simple property
who makes on design time "B" and add it to "A") but then i couldnt see it on
the "InitializeComp onent" methode of the main form, in other words - i
couldnt add to "B" other controls...
i figure that if problem 1 will be solved i wont be bothered by 2 but if
there's something to do on the meantime... :)

10X,

Nov 21 '05 #6
add a reference to system.Design.d ll

\\\\\\
Imports System.Componen tModel
Imports System.Componen tModel.Design
Imports System.Drawing. Design

Public Class MyTabControl
Inherits UserControl

'Windows Form Designer generated code

<Editor(GetType (TabPageCollect ionEditor), GetType(UITypeE ditor))> _
Public ReadOnly Property TabPages() As ControlCollecti on
Get
Return Controls
End Get
End Property
Friend Class TabPageCollecti onEditor
Inherits CollectionEdito r

Public Sub New(ByVal type As System.Type)
MyBase.new(type )
End Sub

Protected Overrides Function CreateCollectio nItemType() As System.Type
Return GetType(MyTabPa ge)
End Function

End Class
End Class

Public Class MyTabPage
Inherits ScrollableContr ol

'...

End class
//////
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Alon" <Al**@discussio ns.microsoft.co m> wrote in message
news:03******** *************** ***********@mic rosoft.com...
hi,
10X for the "CanParent" tip, i solved it through overriding the
"OnControlAdded " method. which is better way to do it ?

and regarding my base problem, i kind of got to the next phase - i now
have
a usercontrol of type "A" who can hold lots of usercontrols of type "B".
if
i drag the "A" and then drag the "B" into "A" i CAN add other controls to
"B". that was my initial meaning !!!
BUT, while this situation is ok, i rather want "A" to have a collection
property of "B"s (like tabcontrol with tabpages etc) with all "B"'s
properties.
this cause me 2 problems:
1) i understood i need a collection class and an item class and lots of
other stuff. is there a good article/code example anywhere about it ?
couldnt
find any that is really thorough... (Joey - i already saw the article you
attached, 10X a lot but this example do not really take care all the
aspects
i need, although when read it, i started to understand what is waiting for
me....:))
2) i kind of succeeded in doing something like a collection (simple
property
who makes on design time "B" and add it to "A") but then i couldnt see it
on
the "InitializeComp onent" methode of the main form, in other words - i
couldnt add to "B" other controls...
i figure that if problem 1 will be solved i wont be bothered by 2 but if
there's something to do on the meantime... :)

10X,

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.775 / Virus Database: 522 - Release Date: 08/10/2004
Nov 21 '05 #7
I have a similar user control designer issue. You mentioned ' I was able to
replicate the .NET TabControl with buttons to click on and panels as detail
where user can drag controls into.' Is there any way you can post that? I
am trying to develop a custom tab control that unfortunately extending the
existing tab control won't do.

"Joey Callisay" wrote:
Joey - it sounds rather complicated. and im not sure it's possible

(although
i didnt try)
as a solution i can always do it all as a component which inherit a panel
and so on... i think it should work but needs a lot more background work
without inheriting the usercontrol...


I was able to replicate the .NET TabControl with buttons to click on and
panels as detail where user can drag controls into. Btw: WinForm controls
including panel is already a component. The idea is to create the control
from IDesignerHost so it is present on the container surface at design time.
http://www.divil.co.uk/net/articles/...oncontrols.asp
by the way, does anyone knows the design attributes that can help me

decides
which controls the user can add on design time to a container (ie panel)

and
which he cant ?


You should attach a custom designer to your custom panel control inheriting
from ParentControlDe signer and then override the CanParent method...

Nov 21 '05 #8

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

Similar topics

0
1838
by: Axel Dahmen | last post by:
Hi, I've created a UserControl containing an <asp:Repeater> control, containing an <asp:Checkbox> control: /------------------------- <asp:Repeater Runat="server" ID="propRpt"> <ItemTemplate> <tr><td> <asp:CheckBox Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Description")%>' TextAlign="Right"/> <asp:Literal Runat="server" Visible="False" Text='<%#DataBinder.Eval(Container.DataItem,"ID")%>'/>
4
7969
by: Mark Friedman | last post by:
I can't seem to figure out how to get a reference to a UserControl in the code-behind for the page that contains the control. All the examples I've seen show how to pass property values from the containing page's HTML to the UserControl but nothing I've seen shows how to reference the UserControl's properties (or subcontrols) from the containing page's server-side code. Note that I'm not creating the UserControl prgrammatically via...
2
1251
by: Lau Lei Cheong | last post by:
Hello, I'm writing a usercontrol that contains a property named "disabled". It is set to false by default but there is also another button in the usercontrol that'll set it to true. On the main form a number of them are displayed. During the On_Load event, 1) It'll check to see if the usercontrol is disabled. If true, the row containing the usercontrol is hidden.
2
6748
by: Ben de Vette | last post by:
Hi, I like to load a UserControl onto a placeholder with some more control then just doing protected System.Web.UI.WebControls.PlaceHolder placeHolder; UserControl ascx = (UserControl)Page.LoadControl("myUserControl.ascx"); placeHolder.Controls.Add(ascx); More something like
2
2247
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 - a form which contains just SessionUserControl TrainingRequestDetails.aspx - a form which includes...
9
14459
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 time. I have to click twice on the controls for the events to be raised, the first time nothing...
4
1190
by: johnb41 | last post by:
I created a UserControl (basically containing a datagridview for showing some data). I need this UserControl to be visible on 2 forms at the same time. Here's a stripped down version of some code: Dim Myusercontrol as UserControlDataGrid Myusercontrol = New UserControlDataGrid Dim myForm1 as new Form1
3
2037
by: Martin | last post by:
Hi ! I've developed a small UserControl with five textbox and label. However, when I want to display the UserControl in a form, controls appear slowly one after one. I've activated double buffering and removed all code in the OnLoad, constructor and I still have the same problem. Here is the code that I use to display the UserControl un the form _objContainer.SuspendLayout();
0
1186
by: qreg | last post by:
I've got a problem with usercontrols and delegating events from the controls that are inside such a usercontrol control. First for a brief description of the problem. I have a user control containing a label and a textbox. I need to linkt the event like click(), mousemove, mousedown etc. in such a manner that clicking the control inside the user control (i.e. label) would result in fireing the event for the usercontrol. This would not be...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9420
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9984
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7401
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
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
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.