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. How to make FolderBrowserDialog TopMost window.

How to make FolderBrowserDialog TopMost window.

Scheduled Pinned Locked Moved C#
helptutorialquestion
2 Posts 1 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.
  • C Offline
    C Offline
    Calla
    wrote on last edited by
    #1

    I have 'Form1' and 'Form2'. Form1 opens up Form2 and Form2 brings up a FolderBrowserDialog (called m_MyBrowser). For the folder strucure to show properly in fbd I have to open this dialog on a different thread like this:

    Thread aThread = new Thread(new ThreadStart(ShowFolderBrowser));
    aThread.SetApartmentState(ApartmentState.STA);
    aThread.Start();

    private void ShowFolderBrowser()
    {
    m_MyBrowser.SelectedPath = string.Empty;
    if (m_MyBrowser.ShowDialog() == DialogResult.Cancel)
    return;
    else
    txtBxLocation.Text = m_MyBrowser.SelectedPath;
    }

    My problem is that I want the m_MyBrowser to be modal and top most (relative to Form2), but since I had to open it in another thread I can't get it to work by simply calling the ShowDialog() method. Does anyone here have any ideas on how to get it modal?

    C 1 Reply Last reply
    0
    • C Calla

      I have 'Form1' and 'Form2'. Form1 opens up Form2 and Form2 brings up a FolderBrowserDialog (called m_MyBrowser). For the folder strucure to show properly in fbd I have to open this dialog on a different thread like this:

      Thread aThread = new Thread(new ThreadStart(ShowFolderBrowser));
      aThread.SetApartmentState(ApartmentState.STA);
      aThread.Start();

      private void ShowFolderBrowser()
      {
      m_MyBrowser.SelectedPath = string.Empty;
      if (m_MyBrowser.ShowDialog() == DialogResult.Cancel)
      return;
      else
      txtBxLocation.Text = m_MyBrowser.SelectedPath;
      }

      My problem is that I want the m_MyBrowser to be modal and top most (relative to Form2), but since I had to open it in another thread I can't get it to work by simply calling the ShowDialog() method. Does anyone here have any ideas on how to get it modal?

      C Offline
      C Offline
      Calla
      wrote on last edited by
      #2

      I seem to have left my brains in the other pants... ShowDialog(IWin32Owner) will do the trick. :-O

      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