[Mono-list] procedures causing app to exit

Jonathan Pobst monkey at jpobst.com
Fri Nov 26 13:10:41 EST 2010


In any gtk# application you will probably want to attach to the 
GLib.ExceptionManager.UnhandledException event so you can handle 
unhandled exceptions instead of the app just exiting.

When you handle that, you can print out the error to the console, which 
may help you find the problem.

Jonathan


On 11/26/2010 12:02 PM, rkamarowski wrote:
>
> when the user presses a button, i'm calling a dialogbox which has treeview
> attached.  whenever i call a procedure the application exits with no errors:
>
> using Gtk;
> using System;
> using System.Windows.Forms;
>
> namespace rakPhotography
> {
> 	public partial class DialogTypeOfPrintEdit : Dialog
> 	{
> 		public class typeOfPrint
> 		{
> 			public typeOfPrint(string name, string active)
> 			{
> 				this.Name = name;
> 				this.Active = active;
> 			}
> 			public string Name;
> 			public string Active;
> 		}
> 		
> 		private ListStore store;
> 		
> 		protected virtual void OnButtonCancelClicked (object sender,
> System.EventArgs e)
> 		{
> 			Destroy();
> 		}
> 		
> 		public DialogTypeOfPrintEdit ()
> 		{
> 			this.Build ();
> 			// list store
> 			store = new ListStore(typeof (string), typeof (string));
> 			// columns
> 			TreeViewColumn colName = new TreeViewColumn();
> 			TreeViewColumn colActive = new TreeViewColumn();
> 			// titles
> 			colName.Title = "Type of Print";
> 			colActive.Title = "Active";
> 			// column widths
> 			colName.MinWidth = 300;
> 			colName.Resizable = true;
> 			colActive.Alignment.Equals(0.5);
> 			colActive.MinWidth = 30;
> 			colActive.MaxWidth = 40;
> 			// cell renderers
> 			CellRendererText nameRenderer = new CellRendererText();
> 			CellRendererToggle activeRenderer = new CellRendererToggle();
> 			nameRenderer.Editable = true;
> 			activeRenderer.Activatable = true;
> 			activeRenderer.Toggled += new ToggledHandler(activeToggle);
> 			activeRenderer.Active = true;
> 			// add renderer to column
> 			colName.PackStart(nameRenderer,true);
> 			colActive.PackStart(activeRenderer,true);
> 			// column number
> 			colName.AddAttribute(nameRenderer,"text",0);
> 			colActive.SetCellDataFunc(activeRenderer, new
> TreeCellDataFunc(renderActive));// .AddAttribute(activeRenderer,"active",1);
> 			// add columns to treeview
> 			treeviewTypeOfPrint.AppendColumn(colName);
> 			treeviewTypeOfPrint.AppendColumn(colActive);
> 			// values
> 			store.AppendValues("Cyanotype",0);
> 			store.AppendValues("Ziatype",1);
> 			
> 			treeviewTypeOfPrint.Model = store;
> 			treeviewTypeOfPrint.Show();
> 			
> 		}
> 		
> 		private void activeToggle(object o,ToggledArgs args)
> 		{
> 			TreeIter iter;
> 			//MessageBox.Show("hi");
> 			if (store.GetIterFromString(out iter, args.Path))
> 			{
> 				bool val = (bool) store.GetValue(iter,1);
> 				store.SetValue(iter,1,!val);
> 				
> 			}
> 			
> 		}
> 		
> 		private void renderActive(TreeViewColumn column, CellRenderer cell,
> TreeModel model, TreeIter iter)
> 		{
> 			typeOfPrint p = (typeOfPrint) model.GetValue(iter,1);
> 			if(p.Active.Equals("1")== true)
> 			{
> 			}
> 			//MessageBox.Show(p.Name);
> 		}
> 	}
> 	
> }
>
> any help would be appreciated.
>
> bob k.



More information about the Mono-list mailing list