473,327 Members | 2,016 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,327 software developers and data experts.

Creating a Windows.Form.Control class for runtime form generation

I have a Windows form which has multiple groups of the same window
controls.
I wanted to create a control class that has the standard controls in
one.

something like:

public class Sensor : System.Windows.Forms.Control
{
private System.Windows.Forms.TextBox Calculation;
private System.Windows.Forms.GroupBox Group;
private System.Windows.Forms.RadioButton Displacement;
private System.Windows.Forms.RadioButton Velocity;
private System.Windows.Forms.RadioButton Acceleration;
private System.Windows.Forms.Label SensorName;
private System.Windows.Forms.Label CalculationName;
..
..
..

Sensor inherites System.Windows.Forms.Control.
I have a location and size for the whole class passed through the
contructor. Then in the Init part of the class I initialize every
member of the class accordingly. When I create an instance of this
class in the Form1 class so that I can display it on the form it
doesn't work.

I tried adding the lines:

this.Controls.Add(this.SensorName);
this.Controls.Add(this.CalculationName);
..
..
..
in the Sensor class itself.

I'm not sure that this is even proper.

In my Form1 class I have the lines:

sensor = new Sensor(p,s,"Sensor Name");
this.Controls.AddRange(new Control[] {sensor});

but again it doesn't seem to add it to my form at run time.

I've seen examples of adding "standard" controls at runtime, so I
imagine that it is possible to do the same with user defined controls.

If anybody can give me a hand with this I would appriciate it very
much.

Thank you in advance.
~sinisa
Nov 15 '05 #1
0 2125

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

Similar topics

4
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...
0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
0
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)):...
3
by: EnglishMan69 | last post by:
Hello All, I am using VB2005 Beta 2 in VS 2005 and am running into a small problem. I need to be able to add a picture box to the main form from within a thread. The program goes to a web...
12
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...
5
by: Guillaume BRAUX | last post by:
Hello, What I want to do is to add a userControl to a form class witch is a different class from the one the button is generated. For example, I want to instanciate a label in "class1" and add...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.