Пример #1
0
        private void ChangeDirBtn_Click(object sender, EventArgs e)
        {
            string selectedPath = null;
            bool AllUsingSamePath = true;
            foreach (DataGridViewRow row in sitesGrid.SelectedRows)
            {
                ObjectView<SiteRecord> ovo = row.DataBoundItem as ObjectView<SiteRecord>;
                if (ovo == null)
                    continue;
                SiteRecord record = ovo.Object;
                if (record != null)
                {
                    if (selectedPath == null)
                    {
                        selectedPath = record.VDir.PhysicalPath;
                    }
                    else if (record.VDir.PhysicalPath == selectedPath)
                    {
                        continue;
                    }
                    else
                    {
                        AllUsingSamePath = false;
                        break;
                    }

                }
            }

            if (!AllUsingSamePath)
            {
                selectedPath = "";
            }

            FolderBrowserDialogEx fd = new FolderBrowserDialogEx();
            fd.Description = "Select a folder to extract to:";
            fd.ShowNewFolderButton = true;
            fd.ShowEditBox = true;
            //dlg1.NewStyle = false;
            fd.SelectedPath = selectedPath;
            fd.ShowFullPathInEditBox = true;
            fd.RootFolder = System.Environment.SpecialFolder.MyComputer;

            // Show the FolderBrowserDialog.
            DialogResult result = fd.ShowDialog();
            if (result == DialogResult.OK)
            {
                selectedPath = fd.SelectedPath;

                foreach (DataGridViewRow row in sitesGrid.SelectedRows)
                {
                    ObjectView<SiteRecord> ovo = row.DataBoundItem as ObjectView<SiteRecord>;
                    if (ovo == null)
                        continue;
                    SiteRecord record = ovo.Object;
                    if (record != null)
                    {
                        record.VDir.PhysicalPath = selectedPath;
                        ovo.BeginEdit();
                        record.Path = record.VDir.PhysicalPath;
                        ovo.EndEdit();
                    }
                }
                sm.CommitChanges();

            }
        }
Пример #2
0
 // Factory Methods
 public static FolderBrowserDialogEx PrinterBrowser()
 {
     FolderBrowserDialogEx x = new FolderBrowserDialogEx();
     // avoid MBRO comppiler warning when passing _rootFolderLocation as a ref:
     x.BecomePrinterBrowser();
     return x;
 }