CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: A menustrip

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    25

    A menustrip

    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:

    Code:
    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!
    Last edited by lost_bg; March 4th, 2010 at 11:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured