[Mono-list] modal FileChooserDialog from FileChooserButton

Brian Pickles brian at bsquaredsen.co.uk
Fri May 19 04:38:35 EDT 2006


Dafnis

Try Form.Show or Form.Run rather than Form.ShowDialog

Brian

On 5/18/06, dafnis <dafnis at ono.com> wrote:
>
> Hi all,
>
> I started learning some C# just two weeks ago and this is the first
> issue I can't solve reading the documentation, lists, etc.
>
> I want the Dialog that pops when you select "Other..." from a
> FileChooserButton to be modal.
> I've tried the following:
>
>
> FileChooserDialog dialog= new FileChooserDialog(
>                 "Choose Output Directory",
>                         window,
>                         FileChooserAction.SelectFolder,
>                         Stock.Cancel,
>                         ResponseType.Cancel,
>                         Stock.Open,
>                         ResponseType.Ok,
>                         null);
>
> dialog.Modal = true;
> dialog.DestroyWithParent = false;
> fcdOut.SelectMultiple = false;
> FileChooserButton button = new FileChooserButton(dialog);
>
>
> but the Dialog is not modal, it stays on top but I still can interact
> with the main window.
> If I use this constructor:
>
>
> FileChooserButton button = new FileChooserButton("Choose Output
> Directory",
>
> FileChooserAction.SelectFolder);
>
>
> the Dialog is not modal, and I have no clue of how to access the
> properties of the underlying FileChooserDialog when using this last
> constructor.
>
> If I use a FileChooserDialog linked to a 'normal' Button instead of a
> FileChooserButton the Dialog is modal as expected:
>
>
> Button bt = new Button("Add Files");
> bt.Clicked += new EventHandler(bt_Clicked);
>
> //...
>
> static void bt_Clicked(object sender, EventArgs e)
> {
>         FileChooserDialog fcd = new FileChooserDialog(
>                 "Choose some files or directories to process",
>                 window,
>                 FileChooserAction.Open,
>                 Stock.Cancel,
>                 ResponseType.Cancel,
>                 Stock.Open,
>                 ResponseType.Ok,
>                 null);
>
>         fcd.SelectMultiple = true;
>         fcd.DestroyWithParent = true;
>         fcd.Modal = true;
>
>         if((ResponseType)fcd.Run() == ResponseType.Ok) {
>                 foreach(string x in fcd.Filenames) {
>                         someListStore.AppendValues(x);
>                 }
>         }
>         fcd.Destroy();
> }
>
>
> I know it would be easier to use the above code to select a directory,
> but I prefer to learn new things.
>
>
> Dafnis
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>



-- 
Brian Pickles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20060519/db24e50c/attachment-0001.html


More information about the Mono-list mailing list