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

Create the controls inside my control

1
Hi all,

I write 2 controls. (Acutally I simplifed my project here) MyTextBox and MyPanel. MyPanel contains a property which is a collection of MyTextBox.

public partial class MyPanel : Panel
{
public MyPanel()
{
InitializeComponent();
}

private MyTextBox[] myTextBox = null;
public MyTextBox[] MyTextBox
{
get { return myTextBox; }
set { myTextBox = value; }
}
}

Inside the MyTextBox usercontrol, I create a TextBox inside it:

public partial class MyTextBox : UserControl
{
public MyTextBox()
{
InitializeComponent();
}

private TextBox textBox = new TextBox();
public TextBox Edit
{
get { return textBox; }
set { textBox = value; }
}
}

After I included MyPanel in my form, I can see the property MyTextBox. I opened the CollectionEditor and add 2 controls, myTextBox1 and myTextBox2

Here is the code generated in form:

private MyPanel myPanel1;
private MyTextBox myTextBox1;
private MyTextBox myTextBox2;

and ...

//
// myPanel1
//
this.myPanel1.Location = new System.Drawing.Point(77, 33);
this.myPanel1.MyTextBox = new WindowsApplication1.MyTextBox[] {
this.myTextBox1,
this.myTextBox2};
this.myPanel1.Name = "myPanel1";
this.myPanel1.Size = new System.Drawing.Size(148, 89);
this.myPanel1.TabIndex = 0;
//
// myTextBox1
//
this.myTextBox1.Location = new System.Drawing.Point(0, 0);
this.myTextBox1.Name = "myTextBox1";
this.myTextBox1.Size = new System.Drawing.Size(150, 150);
this.myTextBox1.TabIndex = 0;
//
// myTextBox2
//
this.myTextBox2.Location = new System.Drawing.Point(0, 0);
this.myTextBox2.Name = "myTextBox2";
this.myTextBox2.Size = new System.Drawing.Size(150, 150);
this.myTextBox2.TabIndex = 0;

No error at all. That's great. But my question is:

I don't want to create the TextBox inside MyTextBox. I want to create it under the form, and remotely use it in MyTextBox. The designer code should be as belows:

private MyPanel myPanel1;
private MyTextBox myTextBox1;
private TextBox textBox1;
private MyTextBox myTextBox2;
private TextBox textBox2;


this.myTextBox1.Edit = this.textBox1

this.myTextBox2.Edit = this.textBox2

This is exactly the same as the way we seen at the DataGrid and DataColumn controls. How can I do that? Any information are welcome.
Jun 28 '07 #1
0 939

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Cindy | last post by:
"kaeli" <infinite.possibilities@NOSPAMatt.net> wrote in message news:MPG.197482677bbc284b989702@nntp.lucent.com... > In article <bed8e3$m6r$1@mawar.singnet.com.sg>, stayhardsg@yahoo.com.sg >...
3
by: Roger | last post by:
Hi In a Windows forms application I have 2 forms A and B; Form B inherits from form A. Form A is never displayed and its only purpose is to be inherited from and therefore contains mostly...
3
by: martin | last post by:
Hi, I am attemping to write a composite control but have so far not achieved the results that I am looking for and would appreciate some advice. By a composite control, i mean, a Web User...
6
by: TomislaW | last post by:
How to find all user controls (ascx) loaded on a Page?
1
by: keithb | last post by:
I have found that I must re-create dynamically added controls on every postback in order to find and access them programatically. The controls I am working with are inside a GridView control. When...
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
5
by: tshad | last post by:
I have a PageInit.ascx that I want to put in all my pages and have it execute only once during the "not IsPostback" section. I also need it to execute first before anything else. I have it set...
7
by: Matt | last post by:
Hi all, I'm trying to create a system where it reads a number of records from a database and then creates a row in the GUI that contains a single field from the database and a button that has a...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.