Results 1 to 3 of 3

Thread: Problem with Events

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Problem with Events

    Hey all, i am using a small form containing a listbox.

    Now what I want to do is if the user double clicks an Item in the listbox, some code will happen and then the form closes.

    So I added the doubleClick Event and tried

    this.close();

    Calling the close method I guess call the dispose method right?

    Now I always get an Exception in the dipose method saying Object listbox cannot be accessed.

    So, how can close the form from this event?

    Thanks Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I need code to play wih it on my computer to see what is wrong.

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Well all you need are two forms. The first one just opens the second one. On the second form add a listbox to it.

    then in your private void InitializeComponent()

    add this:

    Code:
    this.listbox.DoubleClick+= new System.EventHandler(this.ListBox_DoubleClick);
    and then add the EventHandler:

    Code:
    private void ListBox_DoubleClick(object sender, EventArgs e)
    {
    this.Close();
    }
    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

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