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

Is there a C# equivalent of RUNTIME_CLASS ?

In C++, I would typically have a static table of elements like

typedef struct CIconListBoxItem
{
LPCTSTR pszText;
UINT image;
UINT messageID;
bool bDisable;
CRuntimeClass* pView;
}CIconListBoxItem;

where pView is initialised to RUNTIME_CLASS(MyForm)

and will create the form with Createview

Is there an equivalent in C# whereby I can put the class of form I want in a
table and create it as needed ?
Apr 21 '06 #1
3 2091
I don't fully understand the purpose of C++ code you have provided, but if I
understand what you need, the answer is yes, you can store the Type of the
form and create it later.
By Type, I mean System.Type, and by creating, I mean creating an instance of
the specified Type with Activator.

your data structure would like as follows:

class Foo
{
public Type FormType;
}

void CreateAndShowFormFromFoo(Foo foo)
{
Form f = (Form)Activator.CreateInstance(foo.FormType);
f.Show();
}

"Ian Semmel" <is***********@NOKUNKrocketcomp.com.au> wrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
In C++, I would typically have a static table of elements like

typedef struct CIconListBoxItem
{
LPCTSTR pszText;
UINT image;
UINT messageID;
bool bDisable;
CRuntimeClass* pView;
}CIconListBoxItem;

where pView is initialised to RUNTIME_CLASS(MyForm)

and will create the form with Createview

Is there an equivalent in C# whereby I can put the class of form I want in
a table and create it as needed ?

Apr 22 '06 #2
Yes, that's exactly what I wanted, thanks.

Incidentally, it seems to me, that now I am switching forms using this method,
that it is a bit slower. I'm not sure, but I'm not going back to check it out.

Lebesgue wrote:
I don't fully understand the purpose of C++ code you have provided, but if I
understand what you need, the answer is yes, you can store the Type of the
form and create it later.
By Type, I mean System.Type, and by creating, I mean creating an instance of
the specified Type with Activator.

your data structure would like as follows:

class Foo
{
public Type FormType;
}

void CreateAndShowFormFromFoo(Foo foo)
{
Form f = (Form)Activator.CreateInstance(foo.FormType);
f.Show();
}

"Ian Semmel" <is***********@NOKUNKrocketcomp.com.au> wrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
In C++, I would typically have a static table of elements like

typedef struct CIconListBoxItem
{
LPCTSTR pszText;
UINT image;
UINT messageID;
bool bDisable;
CRuntimeClass* pView;
}CIconListBoxItem;

where pView is initialised to RUNTIME_CLASS(MyForm)

and will create the form with Createview

Is there an equivalent in C# whereby I can put the class of form I want in
a table and create it as needed ?


Apr 22 '06 #3
Yes, when using reflection, code will run slower, that's the cost for it.

"Ian Semmel" <is***********@NOKUNKrocketcomp.com.au> wrote in message
news:O5**************@TK2MSFTNGP03.phx.gbl...
Yes, that's exactly what I wanted, thanks.

Incidentally, it seems to me, that now I am switching forms using this
method, that it is a bit slower. I'm not sure, but I'm not going back to
check it out.

Lebesgue wrote:
I don't fully understand the purpose of C++ code you have provided, but
if I understand what you need, the answer is yes, you can store the Type
of the form and create it later.
By Type, I mean System.Type, and by creating, I mean creating an instance
of the specified Type with Activator.

your data structure would like as follows:

class Foo
{
public Type FormType;
}

void CreateAndShowFormFromFoo(Foo foo)
{
Form f = (Form)Activator.CreateInstance(foo.FormType);
f.Show();
}

"Ian Semmel" <is***********@NOKUNKrocketcomp.com.au> wrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
In C++, I would typically have a static table of elements like

typedef struct CIconListBoxItem
{
LPCTSTR pszText;
UINT image;
UINT messageID;
bool bDisable;
CRuntimeClass* pView;
}CIconListBoxItem;

where pView is initialised to RUNTIME_CLASS(MyForm)

and will create the form with Createview

Is there an equivalent in C# whereby I can put the class of form I want
in a table and create it as needed ?



Apr 22 '06 #4

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

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
3
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
1
by: Vannela | last post by:
Is there any equivalent control in .NET for the Power builder DataWindow control? I am explaining the Datawindow architecture to some extent. Power Builder DataWindow Control has got different...
6
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The...
7
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
10
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.