473,624 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2877
If you have a reference to the System.Windows. Forms assembly you can use:

object o = Activator.Creat eInstance(typeo f(System.Window s.Forms.Control ));

If you don;t you need to use:

Type t = Type.GetType("S ystem.Windows.F orms.Control, System.Windows. Forms, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9");
object o = Activator.Creat eInstance(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,docki ng styles and
colors(like XAML for Longhorn).
Thanks for your kind reply..
Regards
Krishna

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

object o = Activator.Creat eInstance(typeo f(System.Window s.Forms.Control ));
If you don;t you need to use:

Type t = Type.GetType("S ystem.Windows.F orms.Control, System.Windows. Forms, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9"); object o = Activator.Creat eInstance(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
3242
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." exception. The problem is that this exception isn't raised somewhere in a method, so it just shows up, and it causes the application to shut down. Is there anyway how to catch this kinds of exceptions? Can I put somewhere a
4
3491
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
4363
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 form from my code dynamically, retrieving the form name from the database. Something like str = "frm_001_UserInfo.cs" and then create an instance of the form using str.
15
6742
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 javascript or vbscript it works. I will appreciate any help. I do the following (C#):
6
1913
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 a new thread to display a customer on the screen for example. However, I have a problem with circular references in my objects which means that I have to load the customer object using reflection ie :
2
1086
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 MyNamespace.ThatClass is in another DLL
2
1295
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
1266
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 appropriate control according to the given name using switch statement, but I'm looking for a more elegant solution using Type class or something like that. Thanks in advance, Shehab.
9
3870
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 case statement like this: sub showHelp(byval frm as String) Select Case (frm) Case "Form1" dim help as new Form1
0
8240
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, 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...
0
8175
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,...
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7168
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, 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...
1
6111
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 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...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2610
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
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
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...

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.