[Mono-list] FileChooserDialog

Lluis Sanchez lluis at ximian.com
Mon Jan 16 12:25:10 EST 2006


If your distro is Suse 10, it might be due to the following (fixed) bug:
https://bugzilla.novell.com/show_bug.cgi?id=132309

El sáb, 14-01-2006 a las 17:47 +0000, Paulo Augusto escribió:
> I am trying to use FileChooserDialog but it is failing me. There isn't
> much documentation about it and, so, i'm trying an example which is
> mostly the same as the example of FileSelection which is in the
> documentation and works fine.
> 
> /******************************************/
> using System;
> using Gtk;
> 
> namespace Aprendizagem
> {
> 	public class ExemploFileChooserDialog
> 	{
> 		Label lbl;
> 		FileChooserDialog fc;
> 		
> 		public ExemploFileChooserDialog ()
> 		{
> 			Application.Init ();
> 			Window win = new Window ("FileSelectionSample");
> 			win.SetDefaultSize (250,200);
> 			win.DeleteEvent += new DeleteEventHandler (Sair);
> 			VBox vbox = new VBox (true, 1);
> 			win.Add (vbox);
> 			Button btn = new Button ("Select a file.");
> 			btn.Clicked += new EventHandler (BtnClicked);
> 			vbox.Add (btn);
> 			lbl = new Label ("Selected: ");
> 			vbox.Add (lbl);
> 			win.ShowAll ();
> 			
> 			fc = new FileChooserDialog ("Choose a folder", win,
> 										FileChooserAction.SelectFolder, null);
> 			fc.Response += new ResponseHandler (OnFileSelectionResponse);
> 			
> 			Application.Run ();
> 		}
> 		
> 		void BtnClicked (object o, EventArgs args)
> 		{
> 			fc.Run();
> 			fc.Hide();
> 		}
> 		
> 		void OnFileSelectionResponse (object o, ResponseArgs args)
> 		{
> 			if (args.ResponseId == ResponseType.Ok)
> 			{
> 				lbl.Text = "Selected: " + fc.Filename + "\n" +
> 					"Folder: " + fc.CurrentFolder;
> 			}
> 		}
> 		
> 		void Sair (object o, DeleteEventArgs args)
> 		{
> 			Application.Quit ();
> 		}
> 	}
> }
> /******************************************/
> 
> When trying to run, the output is this:
> 
> Unhandled Exception: System.NullReferenceException: Object reference not
> set to an instance of an object
> in <0x0019c> Gtk.FileChooserDialog:.ctor (System.String title,
> Gtk.Window parent, FileChooserAction action, System.Object[]
> button_data)
> in <0x0019a> Aprendizagem.ExemploFileChooserDialog:.ctor ()
> in <0x00016> Aprendizagem.Program:Main (System.String[] args)
> 
> Anyone could help me out in what's wrong of if it is some bug!?
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list