Hi MP,
If you want to retrieve the form information of your application, you can
use reflection to do this.
I wrote a sample to get all the forms in the assembly.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Reflection ;
using System.Diagnostics ;
using System.Text ;
namespace reflectionform
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
Process p=Process.GetCurrentProcess();
string assemblyname=p.ProcessName+".exe";
Assembly a=Assembly.LoadFrom (assemblyname);
Module[] modules=a.GetModules();
Type formtype=typeof(System.Windows.Forms.Form);
StringBuilder sb=new StringBuilder();
foreach(Module m in modules)
{
Type []types=m.GetTypes();
foreach(Type t in types)
{
if(t.IsSubclassOf (formtype))
{
sb.AppendFormat("{0}\n",t.Name );
}
}
}
MessageBox.Show(sb.ToString());
}
}
}
Hope this help.
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| From: "MP" <m.******@codetel.net.do>
| References: <eB**************@TK2MSFTNGP12.phx.gbl>
<Dn*********************@news4.srv.hcvlny.cv.net >
| Subject: Re: new property for control type Form
| Date: Sun, 10 Aug 2003 16:21:44 -0400
| Lines: 58
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <OV*************@TK2MSFTNGP12.phx.gbl>
| Newsgroups:
microsoft.public.dotnet.framework.windowsforms,mic rosoft.public.dotnet.frame
work.windowsforms.controls,microsoft.public.dotnet .framework.windowsforms.de
signtime,microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 173stb18.codetel.net.do 64.32.88.173
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms.con trols:10079
microsoft.public.dotnet.framework.windowsforms.des igntime:2816
microsoft.public.dotnet.languages.csharp:175486
microsoft.public.dotnet.framework.windowsforms:499 80
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Is another form in the same project and some time from a reference
project.
|
|
|
| I don't wave any way for now, or any preferences.
|
|
|
| The problem I have is that at some point I want to know if this property
has
| a value, and if it's not empty or null, show the corresponding form.
|
|
|
| TIA
|
|
|
| MP
|
|
| "John Wood" <jw****@spaam.optonline.net> wrote in message
| news:Dn*********************@news4.srv.hcvlny.cv.n et...
| > Where do you expect it to get the list of forms from? All the instances
in
| > your application? How would it know about that at design time anyway?
| >
| > "MP" <m.******@codetel.net.do> wrote in message
| > news:eB**************@TK2MSFTNGP12.phx.gbl...
| > > Hello
| > >
| > > I want to have a public property (and Brows able) in one control, I
use
| > this
| > > code:
| > >
| > > [Browsable(true)]
| > > public System.Windows.Forms.Form recordForm
| > >
| > > get { return _recordForm;}
| > > set {_recordForm = value;}
| > > }
| > >
| > > But when I tried to use it at the properties window I get a combobox
and
| > > only give me options for (none), and the same Form the control is
| > contained.
| > >
| > > I need to put the name of a different Form, is the a way for me to get
| > this
| > > done?
| > > Is this the better approach?
| > >
| > > TIA
| > >
| > > MP
| > >
| > >
| >
| >
|
|
|