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

Creating Forms control using Activator

KK
Hi All
I need to create a windows form control(from System.Windows.Forms.dll
assembly) dynamically using Activator.How do I achieve this?Sample code is
much more helpful.

Thanks in advance

Regards
Krishna
Nov 16 '05 #1
2 2858
If you have a reference to the System.Windows.Forms assembly you can use:

object o = Activator.CreateInstance(typeof(System.Windows.For ms.Control));

If you don;t you need to use:

Type t = Type.GetType("System.Windows.Forms.Control, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
object o = Activator.CreateInstance(t);

Incidently its a bit unusual to want to create aninstance of the base Control class, what are you trying to do

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

Hi All
I need to create a windows form control(from System.Windows.Forms.dll
assembly) dynamically using Activator.How do I achieve this?Sample code is
much more helpful.

Thanks in advance

Regards
Krishna

Nov 16 '05 #2
KK
Basically I'm trying to create controls like TextBox,Panel and Splitter like
controls dynamically and attaching them to my form.These control's
properties are defined in an XML file such as alignment,docking styles and
colors(like XAML for Longhorn).
Thanks for your kind reply..
Regards
Krishna

"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:e0**************@TK2MSFTNGP10.phx.gbl...
If you have a reference to the System.Windows.Forms assembly you can use:

object o = Activator.CreateInstance(typeof(System.Windows.For ms.Control));
If you don;t you need to use:

Type t = Type.GetType("System.Windows.Forms.Control, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"); object o = Activator.CreateInstance(t);

Incidently its a bit unusual to want to create aninstance of the base Control class, what are you trying to do
Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

Hi All
I need to create a windows form control(from System.Windows.Forms.dll
assembly) dynamically using Activator.How do I achieve this?Sample code is much more helpful.

Thanks in advance

Regards
Krishna

Nov 16 '05 #3

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

Similar topics

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."...
4
by: Kimmo Laine | last post by:
Hello, (how) can i do the following (in C#)? // . . . class MyForm : Form { // . . . protected Button myButton = null; protected TextBox myTB = null;
3
by: Bisbal | last post by:
Hi, I'd like to know if it is possible to create a form type from a string. My case: I have a DataTable with forms names (i.e frm_001_UserInfo.cs), and I'd like to create an instance of that...
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...
6
by: Simon Verona | last post by:
I would normally use code such as : Dim Customer as new Customer Dim t as new threading.thread(AddressOf Customer.DisplayCustomer) Customer.CustomerId=MyCustomerId t.start Which would create...
2
by: Jethro | last post by:
Hi all, I have a solution, which contains several projects. Each project occupies the same namespace, and compiles to s different .NET DLL e.g. MyNamespace.ThisClass is in one DLL...
2
by: astroboy | last post by:
How do I create an object of unknown type like this example do in Java http://www.churchillobjects.com/c/11042b.html
2
by: Shehab Kamal | last post by:
I would lik to instantiate the appropriate control/class given its name, such as: Control c = new Control("TextBox") this should create a new TextBox(). I can write my own code that will create the...
9
by: MikeB | last post by:
Hi, I'd appreciate some help, please. I'm writing a VS2005 VB project for school and one of the requirements is that every screen should have a "Help" button. I could do it by writing a clumsy...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

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.