Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. MessageBox with textbox WPF

MessageBox with textbox WPF

Scheduled Pinned Locked Moved C#
csharpwpf
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    juliogyn
    wrote on last edited by
    #1

    I created a window with a field to set the name that the file will be saved. And with the code below I run inside the MainWindow.

    var dialog = new windowFileName();

                if (dialog.ShowDialog() == true)
                {
    
                    MessageBox.Show(dialog.strFileName\_str);
                }
    

    But I'm not getting check if the field is empty. I tried:

    if (dialog.ShowDialog() == false)
    {

                    MessageBox.Show("Please, enter the name file");
    

    dialog.txtFileName.Focus();
    }

    But the dialog close and does not work.

    L 1 Reply Last reply
    0
    • J juliogyn

      I created a window with a field to set the name that the file will be saved. And with the code below I run inside the MainWindow.

      var dialog = new windowFileName();

                  if (dialog.ShowDialog() == true)
                  {
      
                      MessageBox.Show(dialog.strFileName\_str);
                  }
      

      But I'm not getting check if the field is empty. I tried:

      if (dialog.ShowDialog() == false)
      {

                      MessageBox.Show("Please, enter the name file");
      

      dialog.txtFileName.Focus();
      }

      But the dialog close and does not work.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      juliogyn wrote:

      But the dialog close and does not work.

      Of course it does, because the tests you are making only happen after the ShowDialog() method returns. Check http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx[^] for full details of how this operates. You need to trap the events that cause the dialog to be closed, and add your tests there to prevent it closing until the correct data is entered by the user.

      Veni, vidi, abiit domum

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups