FolderBrowserDialog最顶层

时间:2017-08-21 05:53:26

标签: c# winforms

了Firstlogic

FolderBrowserDialog dialog = new FolderBrowserDialog();
           DialogResult ret = STAShowDialog(dialog);

第二逻辑

private DialogResult STAShowDialog(FolderBrowserDialog dialog)
{
    DialogState state = new DialogState();
    state.dialog = dialog;      
   System.Threading.Thread FolderBrowserThread = new System.Threading.Thread(state.ThreadProcShowDialog);
            FolderBrowserThread.SetApartmentState(System.Threading.ApartmentState.STA);
            FolderBrowserThread.Start();
            FolderBrowserThread.Join();
            return state.result;
        }

最后的逻辑

class DialogState
    {
        public DialogResult result;
        public FolderBrowserDialog dialog;

        public void ThreadProcShowDialog()
        {
            dialog.Description = "Select the folder where you want to save the WAV files.";
            result = dialog.ShowDialog(new Form(){TopMost = true,TopLevel = true}           );
        }
    }

FolderBrowserDialog最常用的不起作用。 屏幕层是最低层。

没有错误!我想要Topmost !!!!

我希望在顶层调用

1 个答案:

答案 0 :(得分:0)

private void CreateMyTopMostForm()
{
   // Create lower form to display.
   Form bottomForm = new Form();
   // Display the lower form Maximized to demonstrate effect of TopMost property.
   bottomForm.WindowState = FormWindowState.Maximized;
   // Display the bottom form.
   bottomForm.Show();
   // Create the top most form.
   Form topMostForm = new Form();
   // Set the size of the form larger than the default size.
   topMostForm.Size = new Size(300,300);
   // Set the position of the top most form to center of screen.
   topMostForm.StartPosition = FormStartPosition.CenterScreen;
   // Display the form as top most form.
   topMostForm.TopMost = true;
   topMostForm.Show();
}