I wish to create a class of text boxes (I could use an array but I'd rather use a class).
How do I assign the class a parent (much like textBox.Parent = someForm, etc.)?
Thanks,
I wish to create a class of text boxes (I could use an array but I'd rather use a class).
How do I assign the class a parent (much like textBox.Parent = someForm, etc.)?
Thanks,
Do you want a class that is a collection of textboxes? Or a customized textboxes?
An array and a class is a really different thing.
When you add a control to another (i.e.: if you add a textbox to a panel), .NET will set the parent of the panel automaticly. There is no need or no use of setting a parent, since it's being set as you add a control to another.
When you assign a Parent to a control you are setting a value to a property. If you wish to give your class a Parent you simply need to add a property named Parent:
public Control Parent { get; set; } //.net 3.0 or later shorthand property syntax
As PierlucSS pointed out, classes and arrays are very different. Can you clarify what you wish to acheive so we can better advise on which type to use
An array of text boxes (Name, Stree, City, State, ZIP, phone, etc.) would work but wish to use a class so I can make copies of it instead of creating more arrays.
One class made of text boxes for a customer, one for the person being billed, one for the recipient (shipping address).
Arrays are easy enough but more cumbersome than a class. I don't see where any class has a Parent property.
Thanks,
Wouldn't it be easier to put the textboxes on your form at designer time then jsut store the string values to display in your class? You're going to make a lot of work for yourself if you want to draw the textboxes from your class on to your form.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.