Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I add a member dynamically?

4 views
Skip to first unread message

Muddy Coder

unread,
Apr 21, 2009, 8:09:58 PM4/21/09
to
Hi Folks,

All methods do something about members of a class. The pre-requisite
is that the members had been defined before a method is defined. Now,
I need to add a new member into a class by a method, I mean to add a
new member into a class dynamically. Can I do it?

Application-wise is to control menu items. I don't know how many
selections a user would need, so I allow a user to add in. In
XXX.designer.cs file, a menu selection is a member that is initialized
by method of:

private void InitializeComponent()

Now my goal is to add a new member such as:

private System.Windows.Forms.ToolStripMenuItem
new_member_ToolStripMenuItem;

into my class dynamically. This new member
new_member_ToolStripMenuItem was not initialized by
InitializeComponent()

Can some guru help me out? Thanks a lot!


Muddy Coder

0 new messages