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

Custom control with panel...

I'm trying to build a custom control that includes a panel control on
it. However, in design-time when I drag a new control (e.g. a textbox,
etc) into the panel, it's not added in the panel--just the overall
control.

* I do not want the entire user control to be a panel/container
control. I just want the panel part of it to work as expected.

Any suggestions?

thanks,
Todd

Nov 21 '05 #1
2 2034
You need to implement a Designer for your usercontrol and create the panel
in it's OnSetComponentDefaults() method.

Here's a basic example in VB.

note: you need to add a reference to System.Design.dll.

\\\
Imports System.ComponentModel
Imports System.ComponentModel.Design

<Designer(GetType(MyDesigner))> _
Public Class MyUserControl
Inherits System.Windows.Forms.UserControl

'Your code here

End Class

Friend Class MyDesigner
Inherits System.Windows.Forms.Design.ControlDesigner

Public ReadOnly Property DesignerHost() As IDesignerHost
Get
Return DirectCast(GetService(GetType(IDesignerHost)), _
IDesignerHost)
End Get
End Property

Public ReadOnly Property HostControl() As Control
Get
Return Me.Control
End Get
End Property

Public Overrides Sub OnSetComponentDefaults()
Dim p As Panel = DirectCast(Me.DesignerHost.CreateComponent _
(GetType(Panel)), Panel)
p.Location = New Point(10, 40)
p.Size = New Size(HostControl.Width - 20, HostControl.Height - 50)
p.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or _
AnchorStyles.Right Or AnchorStyles.Bottom
HostControl.Controls.Add(p)
End Sub

End Class
///
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
<to********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I'm trying to build a custom control that includes a panel control on
it. However, in design-time when I drag a new control (e.g. a textbox,
etc) into the panel, it's not added in the panel--just the overall
control.

* I do not want the entire user control to be a panel/container
control. I just want the panel part of it to work as expected.

Any suggestions?

thanks,
Todd

Nov 21 '05 #2
Thank you. That does work. However, if possible i would like to the the
panel on the custom control while designing the custom control. I have
other controls on it, and i'd like to see them all together without
having to compile the project and drag the control onto a form.

thank you,
todd

Nov 21 '05 #3

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

Similar topics

19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
0
by: Tom | last post by:
I am developing a page that will contain multiple instances of a Composite Custom Control that i have developed. The problem is that the user will determine at run time how many of the control...
1
by: Chris Newby | last post by:
I have a custom control that derives from the WebControls.Panel class. In a given ASPX document, I have an instance of my custom control with ID set to "MyControl". Then I put a...
3
by: Charles Zhang | last post by:
I want to create a simple server control that does thing like: <Mc:CollapsibleControl TitlePanelID="panel1" BodyPanelID="Panel2"> <asp:Panel ID="panel1"> ... </asp:Panel> <asp:Panel...
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
3
by: shapper | last post by:
Hello, I have been creating custom controls based on Asp.Net 2.0 controls using CreateChildControls. When I look at the HTML source it looks like Asp.Net wraps all the child controls with a...
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...
2
by: Olorin | last post by:
I'm encountering some weird behavior with the ClientID property. Let's see if I can give you enough info and if anyone has ideas/suggestions. I'm working in ASP.NET 2.0. I have a Web Project with...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.