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

Thread: Form question

  1. #1
    Join Date
    Aug 2000
    Posts
    670

    Question Form question

    If I have the major form, and I created another one, which I need to be pop up when a menu item is pressed, how can I do it?

  2. #2
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    If it is dialog based form use ShowDialog() member. If it should be "normal" window use Show() member:

    Code:
    protected void OnSomeEvent(object sender, EventArgs args)
    {
        FormClass frm = new FormClass();
    
        frm.Show();     // Normal window
    
        // frm.ShowDialog();     // Dialog (modal window)
    }
    martin

  3. #3
    Join Date
    Aug 2000
    Posts
    670
    10x a lot.
    Can you explain how do I do a modal window (dialog)

  4. #4
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    Just create normal form and put there some controls.
    You should add there also button which will close that form. Lets say you want to add there button OK and button Cancel.

    Add both those buttons there and set property DialogResult of those buttons to required value (OK and Cancel).

    Then just show that dialog using ShowDialog() funtion. The function returns with the DialogResult of the button used to close the dialog.

    Code:
    // ....
    DialogResult dlgResult = YourNewForm.ShowDialog();
    if (dlgResult == DialogResult.OK)
        MessageBox.Show("You close your dialog by pressing OK button");
    Martin

  5. #5
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    RYE,
    ShowDialog is Modal dialog.
    if you are looking for MDI application then

    you can have a quick look at microsoft MDI application

    which is attached here
    Attached Files Attached Files

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