473,657 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to clone container control (with child control inside it) like a group box

I'll make this post as short as possible.

1. Put a GroupBox on a window form. Put a Button and TextBox inside the
GroupBox .
2. Select the group box, do copy and paste inside the same windows form
(or different window form, doesnt matter).
3. Now I have another copy (or clone) of the GroupBox with a Button
and a Texbox control inside it. They have different name (should be
groupBox2, button2 and textBox2).

However I want to do this with code. I try this

----------------------------------------------------------------------
GroupBox groupNewBox = groupBox1;
----------------------------------------------------------------------

But this is groupNewBox is referencing groupBox1.

I can do this,

----------------------------------------------------------------------
GroupBox groupNewBox = new GroupBox();
groupNewBox.Tex t = groupBox1.Text;
Foreach( Control ctrl in groupBox.Contro ls)
{
//take each control and manually recreate the
//control as child of groupNewBox
}
----------------------------------------------------------------------

But what I REALLY want todo is something like this

----------------------------------------------------------------------
GroupBox groupNewBox;
groupBox1.Clone To(groupNewBox) ;
----------------------------------------------------------------------

Without having to extend GroupBox to something like CloneableGroupB ox.

Appreciate any reply to this.

May 18 '06 #1
0 1265

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

Similar topics

6
2232
by: Patrick Coghlan | last post by:
I want to create about 4 forms with the same dimensions and background colours, similar to the forms one has to traverse when installing various software packages. I'm using Visual Studio and C++ (changing to C# soon) and can create separate forms, but I really just want to clone the first one, have the user select different options on each form and navigate between them via the PREV-NEXT-OKAY-CANCEL buttons on the bottom of the form. ...
0
1126
by: George Jordanov Ivanov | last post by:
Hi there, I have a problem related with validation of a container control, containing other container controls. Scenario: I have a dialog based Windows form, containing a group control (which is a container also). The group control contains multiple other simple controls - 2 text boxes and 3 combo boxes. The form has 2 buttons representing the well-known OK and Cancel buttons. What I am trying to do: I handle Validating event for all...
16
2507
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some of properties or assign event handlers. I need to be able to clone the manipulated control at runtime. I could use the Clone method of some objects (like Font, Style, String,
14
8614
by: Hamed | last post by:
Hello It seems that I should implement ICloneable to implement my own clone object. the critical point for me is to make a control object based on another control object that all of its event handlers are set like the old one. Is there a way to do this job? For example, is there a way to use EventInfo object to get all event handlers of the old control in runtime and set my new cloned control events to the event handlers of the old...
15
6505
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
0
6644
by: syntax | last post by:
Hi, I am quite new to C# .NET, trying to understand the MDI Parent / Child form relations.. currently have an issue with regards to adding a child form to a mdi parent split container panel via method inside another child form. The squence of events as follows : MDI Parent MDIMain loaded MDI Child Form1 loaded Form1 should load MDI Child Form2 and adds it to split container panel2 in MDIMain, finally display Form2 inside the MDIMain...
7
2765
by: Marcolino | last post by:
Hi, another question for you. I looked around but found nothing. I have a MDI container calld frmMDIMain, that contain some child form....one of that forms is called frmPostIt and I need that form stay always on top of all other child contained in MDI. is possinble to do this? Many thanks in advance
5
4109
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 to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
9
8008
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-)) When I set the label with "SendToBack", it completely disapears. I also tried to set the child form like "BringToFront" but this also does not help.
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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,...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
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
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
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
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.