Computing.Net > Forums > Programming > C# .net object names

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C# .net object names

Reply to Message Icon

Name: ScottStrommen
Date: February 9, 2005 at 07:56:58 Pacific
OS: Windows 2000
CPU/Ram: p4/ 1gig
Comment:

In Foxpro you may use addobject() to add an object of any name to an existing object. These objects may be of any name or number and their names and numbers and types can be completely data driven. In C# however, I have not found a way to do this. In C# you must declare the objects name and know exactly how many objects you need at compile time. Does anyone know how to make the name and number of added objects data driven in C# .net.

thanks

Scott



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: February 10, 2005 at 03:44:25 Pacific
Reply:

C# and Foxpro are completely different things. C# is a programming language, Foxpro is a database language.

but of course you can add objects on the fly:

All you need to do is create a new instance of the control you want to create, set it's attributes and then add this.Controls.Add([yourcontrol);

example:
//lets pretend that you have read a database that defines a bunch of labels

while(Reader.Read())
{
System.Windows.Forms.Label newLabel = new Label();
newLabel.AutoSize = true;
newLabel.BackColor = System.Drawing.SystemColors.Control;
newLabel.Enabled = true;
newLabel.Left = int.parse(Reader["Left"].ToString());
newLabel.Name = Reader["labelname"].ToString();
newLabel.Parent = this;
newLabel.Text = [database text value];

newLabel.Top = int.parse(Reader["Top"].ToString());
newLabel.Width = int.parse(Reader["Width"].ToString());
this.Controls.Add(newLabel);


hope this helps,
Chi

Happy Decemberween, Everybody!


0
Reply to Message Icon

Related Posts

See More


When to use ALT instead o... MySQL ERROR 2003



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C# .net object names

eof() is missing in VS C++ NET 2003 www.computing.net/answers/programming/eof-is-missing-in-vs-c-net-2003/9931.html

Working with rs232 in Visual C.Net www.computing.net/answers/programming/working-with-rs232-in-visual-cnet/10985.html

Visual C++ .Net www.computing.net/answers/programming/visual-c-net/15053.html