Hi i just have a quick question.
I ran a search but i was not sure really how to word it correctly and couldnt find anything.
I would like to know how I can create a form object like a textbox, label or combo box from the one variable?
Obviously for a label it is easy by itself, i have just been doing..
public System.Windows. Forms.Label[,] obj_field_contr ol = new System.Windows. Forms.Label[19, 9];
but now i want to have this public declaration as a variant type array that allows me to create different objects depending on what i assign it. Is this only possible through inheritence?
I want to make it
public System.Windows. Forms.VariantOb jectThing[,] obj_field_contr ol = new System.Windows. Forms.VariantOb jectThing[19, 9];
and then simply be able to do
obj_field_contr ol[0, 0] = new System.Windows. Forms.TextBox() ;
obj_field_contr ol[0, 1] = new System.Windows. Forms.Label();
obj_field_contr ol[0, 2] = new System.Windows. Forms.ComboBox( );
I would appreciate any help :)
Thanks
5 2039
I am moving this to the .NET forum.
Plater 7,872
Recognized Expert Expert
Hmm.
You might be able to get away with using an array of Control[,] and then assigning the various index positions to be a TextBox or Label or whatever.
There is also a ControlCollecti on object that you can .Add() to?
Although you might consider trying to use a more generic approach and using like LinkedList (LinkedList<Con trol>) or ArrayList.
Hi thanks for the replys guys. Also sorry, i thought i did post it in the .net forum.
You suggested using the .control fuction correct? i have actually tried this before, but maybe my method was incorrect...
i have tried:
public System.Windows. Forms.Control[,] obj_field_contr ol = new System.Windows. Forms.ComboBox[19, 9];
Just to see if any of of the combobox controls would actually work. However i get an error saying that the .item is not a recognised command for a control.
I have also tried:
public System.Windows. Forms.Control[,] obj_field_contr ol = new System.Windows. Forms.Control[19, 9];
obj_field_contr ol[0, 1] = new System.Windows. Forms.TextBox() ;
But it gave my the same kind of problem, as it only gives a generic amount of commands for the control.
That control collection add sounds like a good idea, but after i have added the object, how do i actually reference it?
obj_field_contr ol[0, 1].Add(new System.Windows. Forms.TextBox() );
What would i make this so i can reference the location of the textbox?
obj_field_contr ol[0, 1].Location
EDIT
I have found that if i write the syntax like this:
obj_field_contr ol[0, 1][0].Location
It works, however i find that the [0] is a bit of a pain as it will remove some of the efficiency of my program. Any ideas?
EDIT 2:
After trying it out a little bit i have still found that the control collection will not allow me to use properties that are uncommon with all objects. The .Item will still not work. Any suggestions?
Thanks for the help.
I managed to fix it myself. I just ended up using a Control and then type casting the controls like (TextBox). Works like a charm. Thanks
Plater 7,872
Recognized Expert Expert
Yeah after your other post I was going to say you need to remember to cast the control back to it's correct type to get all the extra properties and such.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Altramagnus |
last post by:
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.
When I try to create them, I get "Error creating window handle"
My guess is there is a maximum number of window handle, because if I reduce
to about 2 instances of each window,
it can run. But not 20 instances of each window.
Does anyone know what the problem is? is it really because it exceeds the
maximum number of window handle?
|
by: Darleen |
last post by:
I am seeking conceptual here on how to get started with a "3D Matrix"
in Access. We run a training center which holds multiple classes in
multiple cities at multiple times. So I need to create a matrix with
3 "axis". The 3 axes are:
City Location
Week of Class (in 14 week increments that repeat)
Name of Class
The end goal is to be able to have a form that shows these classes in
|
by: Jason M |
last post by:
Hi,
Im very new to c#, so forgive me if this is a really stupid question.
Im trying to create a form for entering purchase requests.
For each line item I have a quantity, a description unit cost and total cost.. all textboxes.
Next to this I have a button that will add a new set of textboxes so people can have more than one line item.
As it is now, when you push the button the textboxes appear, and everything below them is moved down...
|
by: Ken Varn |
last post by:
I am just starting the process of creating ASP.NET server controls. I have
created controls for .NET applications, but have just started with ASP.NET.
I am a little confused about some areas that I am hoping someone can help
clear up.
1. What is the difference between initializing a control in the
constructor, vs the OnInit(), vs the CreateChildControls() methods?
2. The control that I created contains an Items collection attribute...
|
by: |
last post by:
Trying to learn about manipulating collections of objects, and populating
these objects dynamically from datasources. Could someone post a code sample
that shows the following:
Instantiating a collection object -- say, a dictionary.
Populating that collection object with custom objects, say, Person. What I
really want to see is how to populate the properties of those Person objects
from a datasource: instantiate one Person, fill...
| |
by: Mats Lycken |
last post by:
Hi,
I'm creating a CMS that I would like to be plug-in based with different
plugins handling different kinds of content.
What I really want is to be able to load/unload plugins on the fly
without restarting the application.
What I did was to create an AppDomain that loaded the plugins and
everything was great, until I tried to pass something else that strings
between the domains...
|
by: Tabi |
last post by:
Hi,
I have just created a class that removes action attribute from HtmlForm. The
code looks like here.
namespace ComIT.Applications.Common
{
public class Form : System.Web.UI.HtmlControls.HtmlForm
{
protected override void RenderAttributes(HtmlTextWriter writer)
|
by: Ralph |
last post by:
Hi
I don't understand why it's not working:
function schedule(imTop){
this.tdImagesTop = imTop;
}
schedule.prototype.selectEl = function() {
alert(this.tdImagesTop);
|
by: nyathancha |
last post by:
Hi,
How Do I create an instance of a derived class from an instance of a
base class, essentially wrapping up an existing base class with some
additional functionality. The reason I need this is because I am not
always able to control/create all the different constructors the base
class has. My problem can be described in code as follows ...
/* This is the base class with a whole heap of
constructors/functionality*/
public class Animal
|
by: Doc John |
last post by:
I need to create several Windows Forms and I'm thinking of creating a base
Form from which I can derive all Forms. Is it possible to include something
in that Base Form so that all Forms I create will use some specific controls
with some specific properties? For example, if I add to the Base Form a
button with a black background ans Arial Font, will all the Forms be
required to use this same Button?
Thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |