lost_bg
March 2nd, 2010, 11:53 AM
Two weeks ago I have posted a question about menu driven menustip. I didn't really get solution to my questions, but I got something to start fo- the main idea. But now I am stuck to it again:
I got the following code from a member fromt his forum:
testDBDataContext db = new testDBDataContext();
List<tablename> lst = (from table in db.lesons
select table).ToList();
foreach (tablename tbl in lst)// this will populate all your menuitems
{
ToolStripItem itm = new MenuItem(tbl.name); //Create a new menuitem
itm.Click += new EventHandler(itm_Click); //assign event handlers for the OnClick event
this.MenuItem.Add(itm);
}
But I get the following errors:
Error 2 The name 'itm_Click' does not exist in the current context C:\Users\Lost\Documents\Visual Studio 2008\Projects\testproject\testproject\Teacher\Teachermain.cs 22 47 testproject
Error 3 'WindowsFormsApplication1.Teachermain' does not contain a definition for 'MenuItem' and no extension method 'MenuItem' accepting a first argument of type 'WindowsFormsApplication1.Teachermain' could be found (are you missing a using directive or an assembly reference?) C:\Users\Lost\Documents\Visual Studio 2008\Projects\testproject\testproject\Teacher\Teachermain.cs 23 22 testproject
Also I need it to populate a menuStrip1, and I am not sure that it is really doing this.
I have searched how to do it for hours, but I couldn't get anything to work.
I awfully need this and I will be really happy if someone tells me how it sohuld be rewritten.
Thanks in advance!
I got the following code from a member fromt his forum:
testDBDataContext db = new testDBDataContext();
List<tablename> lst = (from table in db.lesons
select table).ToList();
foreach (tablename tbl in lst)// this will populate all your menuitems
{
ToolStripItem itm = new MenuItem(tbl.name); //Create a new menuitem
itm.Click += new EventHandler(itm_Click); //assign event handlers for the OnClick event
this.MenuItem.Add(itm);
}
But I get the following errors:
Error 2 The name 'itm_Click' does not exist in the current context C:\Users\Lost\Documents\Visual Studio 2008\Projects\testproject\testproject\Teacher\Teachermain.cs 22 47 testproject
Error 3 'WindowsFormsApplication1.Teachermain' does not contain a definition for 'MenuItem' and no extension method 'MenuItem' accepting a first argument of type 'WindowsFormsApplication1.Teachermain' could be found (are you missing a using directive or an assembly reference?) C:\Users\Lost\Documents\Visual Studio 2008\Projects\testproject\testproject\Teacher\Teachermain.cs 23 22 testproject
Also I need it to populate a menuStrip1, and I am not sure that it is really doing this.
I have searched how to do it for hours, but I couldn't get anything to work.
I awfully need this and I will be really happy if someone tells me how it sohuld be rewritten.
Thanks in advance!