473,386 Members | 1,819 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.

Windows User Control as a container

Sam
Please help!

I want to create a user control that can act as a container for other
controls
(like a panel or a groupbox).
The control will consist of a panel that acts as the container for external
controls plus
some other stuff.
I hoped that all I needed to do would be to implement
System.ComponentModel.IContainer,
and pass everything through to the panel in my user control.
This doesn't appear to work, can anyone help?

Thanks.

Public Class My_Control

Inherits System.Windows.Forms.UserControl
Implements System.ComponentModel.IContainer

...

Public Sub Add(ByVal component As System.ComponentModel.IComponent)
Implements System.ComponentModel.IContainer.Add
Panel1.Container.Add(component)
End Sub

Public Sub Add2(ByVal component As System.ComponentModel.IComponent,
ByVal [name] As String) Implements System.ComponentModel.IContainer.Add
Panel1.Container.Add(component, name)
End Sub

Public ReadOnly Property GetComponents() As
System.ComponentModel.ComponentCollection Implements
System.ComponentModel.IContainer.Components
Get
GetComponents = Panel1.Container.Components
End Get
End Property

Public Sub Remove(ByVal component As System.ComponentModel.IComponent)
Implements System.ComponentModel.IContainer.Remove
Panel1.Container.Remove(component)
End Sub

End Class


Nov 20 '05 #1
2 9745
Hi,

All you have to do is use me.setstyle(ControlStyles.ContainerControl)
to make your control a container.
http://support.microsoft.com/default...b;en-us;305079

Ken
--------------------
"Sam" <no****@do.not.send> wrote in message
news:bp**********@micra.nasoftware...
Please help!

I want to create a user control that can act as a container for other
controls
(like a panel or a groupbox).
The control will consist of a panel that acts as the container for external controls plus
some other stuff.
I hoped that all I needed to do would be to implement
System.ComponentModel.IContainer,
and pass everything through to the panel in my user control.
This doesn't appear to work, can anyone help?

Thanks.

Public Class My_Control

Inherits System.Windows.Forms.UserControl
Implements System.ComponentModel.IContainer

...

Public Sub Add(ByVal component As System.ComponentModel.IComponent)
Implements System.ComponentModel.IContainer.Add
Panel1.Container.Add(component)
End Sub

Public Sub Add2(ByVal component As System.ComponentModel.IComponent,
ByVal [name] As String) Implements System.ComponentModel.IContainer.Add
Panel1.Container.Add(component, name)
End Sub

Public ReadOnly Property GetComponents() As
System.ComponentModel.ComponentCollection Implements
System.ComponentModel.IContainer.Components
Get
GetComponents = Panel1.Container.Components
End Get
End Property

Public Sub Remove(ByVal component As System.ComponentModel.IComponent)
Implements System.ComponentModel.IContainer.Remove
Panel1.Container.Remove(component)
End Sub

End Class

Nov 20 '05 #2
Sam
This doesnt seem to work, and the documentation is useless.
Am I missing something really obvious here?
Does an example exist of creating a user-defined container control?
I've tried searching the internet but the only references I can find are
in expensive .net training courses.


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e9*************@TK2MSFTNGP11.phx.gbl...
Hi,

All you have to do is use me.setstyle(ControlStyles.ContainerControl) to make your control a container.
http://support.microsoft.com/default...b;en-us;305079

Ken
--------------------
"Sam" <no****@do.not.send> wrote in message
news:bp**********@micra.nasoftware...
Please help!

I want to create a user control that can act as a container for other
controls
(like a panel or a groupbox).
The control will consist of a panel that acts as the container for

external
controls plus
some other stuff.
I hoped that all I needed to do would be to implement
System.ComponentModel.IContainer,
and pass everything through to the panel in my user control.
This doesn't appear to work, can anyone help?

Thanks.

Public Class My_Control

Inherits System.Windows.Forms.UserControl
Implements System.ComponentModel.IContainer

...

Public Sub Add(ByVal component As System.ComponentModel.IComponent)
Implements System.ComponentModel.IContainer.Add
Panel1.Container.Add(component)
End Sub

Public Sub Add2(ByVal component As System.ComponentModel.IComponent,
ByVal [name] As String) Implements System.ComponentModel.IContainer.Add
Panel1.Container.Add(component, name)
End Sub

Public ReadOnly Property GetComponents() As
System.ComponentModel.ComponentCollection Implements
System.ComponentModel.IContainer.Components
Get
GetComponents = Panel1.Container.Components
End Get
End Property

Public Sub Remove(ByVal component As System.ComponentModel.IComponent) Implements System.ComponentModel.IContainer.Remove
Panel1.Container.Remove(component)
End Sub

End Class


Nov 20 '05 #3

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

Similar topics

0
by: Zi | last post by:
I have a user control within a data grid. I am binding the user control to one of the values from the data grid. The data grid implements paging. It is all working ok for the first page but once i...
6
by: Mary Kerrigan | last post by:
I have a user control (menu) with a data list: <asp:DataList id="MyList" runat="server"> <ItemTemplate> <asp:hyperlink cssclass="MenuUnselected" id="myLink1" Text='<%#...
2
by: tshad | last post by:
This is related to my other Hiding datalistitems problem that I can't seem to solve. I have tried different methods which all seem to work only partially. I decided to try to use a User...
0
by: sda | last post by:
Hi everybody, I have a problem to fire an event in a DataGrid. 1/ I have got a datagrid in a generic user control protected System.Web.UI.WebControls.DataGrid dgListDataGrid; ........ ...
6
by: Art | last post by:
Hi I'm new at this and need some help. I have a "solution" with 2 projects - the main project and a library. The library is simple, it contains a text box that will appear many times in the form...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
1
by: Efi Merdler | last post by:
Hi, I created a user control, but instead of handling exception in the user control level I prefer to handle them in the containing form. In the load event of the containing form I'm using:...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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.