473,657 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open a form

Hi,

I Want to open a form that a user specify in a textbox...
Thereis any way to open a form having justt only is name?

Ex: txtForm.Text = "frmSomethi ng"
Form oform= new (Form)txtForm.T ext.ToString();
oform.open();
Nov 15 '05 #1
6 4224
Use Activator class' CreateInstance( ) / CreateInstanceF rom() methods.
Arild

"Bernardo" <bp****@sapo.pt > wrote in message
news:4A******** *************** ***********@mic rosoft.com...
Hi,

I Want to open a form that a user specify in a textbox...
Thereis any way to open a form having justt only is name?

Ex: txtForm.Text = "frmSomethi ng"
Form oform= new (Form)txtForm.T ext.ToString();
oform.open();

Nov 15 '05 #2
Hi Arild,

Could you provide us with an example please?

Thanks,

W.

"Arild Bakken" <ar*****@hotmai l.com> wrote in message
news:Or******** ******@TK2MSFTN GP10.phx.gbl...
Use Activator class' CreateInstance( ) / CreateInstanceF rom() methods.
Arild

"Bernardo" <bp****@sapo.pt > wrote in message
news:4A******** *************** ***********@mic rosoft.com...
Hi,

I Want to open a form that a user specify in a textbox...
Thereis any way to open a form having justt only is name?

Ex: txtForm.Text = "frmSomethi ng"
Form oform= new (Form)txtForm.T ext.ToString();
oform.open();


Nov 15 '05 #3
Hi,

Here's an example (not tested though):

Form oForm = (Form)System.Re flection.Assemb ly.CreateInstan ce(
txtForm.Text);
oForm.Show();

NOTE: The example assumes the form to be created resides in the same
assembly that
contains the code above.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Bernardo" <bp****@sapo.pt > wrote in message
news:4A******** *************** ***********@mic rosoft.com...
Hi,

I Want to open a form that a user specify in a textbox...
Thereis any way to open a form having justt only is name?

Ex: txtForm.Text = "frmSomethi ng"
Form oform= new (Form)txtForm.T ext.ToString();
oform.open();


Nov 15 '05 #4
From the docs on the Activator class:

ObjectHandle hdlSample;
IMyExtenderInte rface myExtenderInter face;
object[] activationAttri butes = {new Synchronization Attribute()};

// Assumes that SampleAssembly. dll exists in the same directory as this
assembly.
hdlSample = Activator.Creat eInstanceFrom(" SampleAssembly. dll",
"SampleNamespac e.SampleClass", activationAttri butes);

// Assumes that the SampleClass implements an interface provided by
// this application.
myExtenderInter face = (IMyExtenderInt erface)hdlSampl e.Unwrap();
All you need to do is replace "IMyExtenderInt erface" with "Form" since all
Forms inherit from that class, and ofcourse use the correct assemblyname and
classname.

Arild
"Wesam" <pu*********@ho tmail.com> wrote in message
news:uC******** ******@TK2MSFTN GP10.phx.gbl...
Hi Arild,

Could you provide us with an example please?

Thanks,

W.

"Arild Bakken" <ar*****@hotmai l.com> wrote in message
news:Or******** ******@TK2MSFTN GP10.phx.gbl...
Use Activator class' CreateInstance( ) / CreateInstanceF rom() methods.
Arild

"Bernardo" <bp****@sapo.pt > wrote in message
news:4A******** *************** ***********@mic rosoft.com...
Hi,

I Want to open a form that a user specify in a textbox...
Thereis any way to open a form having justt only is name?

Ex: txtForm.Text = "frmSomethi ng"
Form oform= new (Form)txtForm.T ext.ToString();
oform.open();



Nov 15 '05 #5
Hi

This cod
Form oform = (Form)System.Re flection.Assemb ly.CreateInstan ce(txtNomeEcran .Text)

raises an error:
An object reference is required for the nonstatic field, method, or property 'System.Reflect ion.Assembly.Cr eateInstance(st ring)

Can you help
Thanks a lot
Nov 15 '05 #6
=?Utf-8?B?QmVybmFyZG8 =?= <bp****@sapo.pt > wrote:
This code
Form oform = (Form)System.Re flection.Assemb ly.
CreateInstance( txtNomeEcran.Te xt);

raises an error:
An object reference is required for the nonstatic field, method,
or property 'System.Reflect ion.Assembly.Cr eateInstance(st ring)'

Can you help?


Yes - you need to specify *which* assembly to use to create the
instance. You're using it as if CreateInstance were a static method,
which it's not.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #7

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

Similar topics

1
462
by: Konstantin | last post by:
Can someone help me figure out a way to open a form only once in an MDI app. I have an MDI app that contains several forms. I use each form depending on the type of document that the user needs to see, i.e. for documents of type A, I use form A, for type B, form B, etc. Each document has a unique number. I need the app to only show one document at a time, i.e. ifthe user tries to open doc. 1 of type A, then open form A and load doc 1....
2
4093
by: Julia Baresch | last post by:
Hi everyone, As some of you may know, we've been having trouble with an unrecognized database format error. Today I installed an unfinished project on the workstation of one of my users. It's a query by form in which she enters the criteria of the record she wants in an unbound form, and it pulls only that record and switches to the entry form so she can enter data. I had noticed it was faster than find or filter, so I offered it to...
1
10069
by: petersk | last post by:
Firstly I am an older person trying to teach myself to create a project and teach myself Access VBA programming along the way. I anticipate a number of problems I will need help with but here goes with the first >From one form I want to open another form to extract data. I really want to do this with the form Hidden but initially show the form open so that I can easily check what is going on.
14
3762
by: Simon Abolnar | last post by:
I would like to know how to open child form from dialog form. Thanks for help! Simon
3
2804
by: rdemyan via AccessMonster.com | last post by:
My application is split into a front end and back end. Each user has their own copy of the front end. There are a few forms I only want to be open for one user at a time. So I've implemented the following strategy: 1) Create a table with the fields FormName, OpenStatus, FormUser 2) When a user tries to open the form, the code in the Form Load event checks the table for the OpenStatus value (True/False). 3) If the status is True, then...
13
2935
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the events.. But the regular forms that are also open do not receive that event. This is true whether there are child forms open or not.
6
2644
by: Bob Alston | last post by:
Looking for someone with experience building apps with multiple instances of forms open. I am building an app for a nonprofit organizations case workers. They provide services to the elderly. so far I have built a traditional app, switchboard, forms, etc. Part of this app is to automate the forms they previously prepared manually. After the app was built and works just fine, I find out there are several case managers using MS word...
10
1956
waynetheengineer
by: waynetheengineer | last post by:
Hi, I'm trying to write code for a form when it closes. It's supposed to requery a combo box depending on which form is currenlty open in the background behind the current form, shown below: Private Sub Form_Close() If Forms(frmProjecTotal).CurrentView <> 0 Then Forms!!.Requery Else Forms!!.Requery
19
19034
by: =?Utf-8?B?R3JlZw==?= | last post by:
How can I tell via code if a Form is already open. Each time my forms load I have some initialization code that runs, but if the form is already open and hidden I don't want that initialization code to run. Thus, I just want to unhide the form. My thought is eveyrtime I go to load a form I could scan through all the open forms in my project and determine whether the one I'm getting ready to load is open or not.
5
7636
by: billa856 | last post by:
Hi, My project is in MS Access 2002. In that I want to open one form multiple times. I put one button on my main form. Now whenever I click on that button than form will be open. Now when I click again on that same button than it will open same form again in seperate window. But instead of that already open form comes.and so i couldn't open that form multiple times. Already open form must be remain as it is even if I click on that button...
0
8407
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
8319
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
8739
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...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
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 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...
0
7347
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...
0
5638
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();...
0
4171
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...
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.