Welcome to RenEvo Sign in | Join | Help
in
Home Wiisis Blogs Forums Photos Downloads About

using ToolStripMenuItem in c#

Last post 12-12-2006, 2:25 PM by hinch. 5 replies.
Sort Posts: Previous Next
  •  12-10-2006, 7:33 AM 330

    using ToolStripMenuItem in c#

    This is a really annoying little problem i'm having and for some reason I can't seem to work my head around it.

     

    so i'm attempting to make a very simple .net IRC client and one of the problems i'm having is i've made an exit button declared as follows

     
    private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; 

    now using the following to capture the onclick event and close the app

    private void exitToolStripMenuItem_click(object sender, EventArgs e)
            {
                    // exit app
                    Application.Exit();
            }

     

    however the app doesnt shutdown on click oO any suggestions?
     

  •  12-10-2006, 2:10 PM 335 in reply to 330

    Re: using ToolStripMenuItem in c#

    your listen thread is still going, i am guessing that you are using a form for the startup object, if that is the case, instead of doing application.exit, do this.close()

    also, with the way that c# events happen, did you make sure that the event is registered?

    Hope that helps.


    Advertising has us chasing cars and clothes, working jobs we hate so we can buy shit we don't need.
  •  12-10-2006, 3:08 PM 337 in reply to 335

    Re: using ToolStripMenuItem in c#

    "also, with the way that c# events happen, did you make sure that the event is registered?"

    came to this conclusion myself after stressing out over it for some reason the _click event isn't being registered (I replaced the application.exit with a line to fill a text box with "exit clicked"

    which as expected didnt populate. so any clues/suggestions how to make the toolstripmenu stuff broadcast its events through the app? (even though the menu bar was created using the built in wizard which should do all that for me anyway afaik
     

  •  12-10-2006, 9:27 PM 342 in reply to 330

    Re: using ToolStripMenuItem in c#

    exitToolsStripMenuItem.OnClick += exitToolStripMenuItem_click;

    thats from memory, might not be exact, but that should be in your forms "InitializeComponent".

     


    Advertising has us chasing cars and clothes, working jobs we hate so we can buy shit we don't need.
  •  12-11-2006, 5:06 AM 363 in reply to 342

    Re: using ToolStripMenuItem in c#

    right going to poke it again tonight i do find it strange we have to manually trap the event though i'd have thought since the stripmenu object is created with a wizard that it would also have registered all the events in too.

    anyway will let you know how it goes roll on the mini hinch-irc client :)
     

  •  12-12-2006, 2:25 PM 403 in reply to 363

    Re: using ToolStripMenuItem in c#

    this.exitToolStripMenuItem.Click += exitToolStripMenuItem_click;

     

    in private void InitializeComponent() works fine but has to appear above the  

    this.menuStrip1.SuspendLayout();
    this.SuspendLayout(); 

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems