[Gtk-sharp-list] TreeView Model and GetIter/GetValue

Rob Hudson rob at euglug.net
Wed Jul 6 01:35:19 EDT 2005


Hello,

I'm new to the list and was inspired by Nat's screencast on how easy it 
looked using Glade and Gtk# so I'm attempting a small app.

I'm getting an error when I try to get a handle on the model used in the 
TreeView...
Main.cs(77) error CS0165: Use of unassigned local variable `recipetree'
Main.cs(78) error CS0165: Use of unassigned local variable `m'
Main.cs(79) error CS0029: Cannot convert implicitly from `object' to 
`string'

There's other errors but I can't seem to get past the error on line 77. 
  The variable recipetree is accessible in my MainClass constructor 
where I've used it to load values into the tree using AppendColumn(...).

Any help would be appreciated.

Here's my code with pieces removed for clarity...

using System;
using Gtk;
using Glade;

class MainClass
{
	[Widget] Gtk.TreeView recipetree;

	public static void Main(string[] args)
	{
		new MainClass(args);
	}

	public MainClass (string[] args)
	{
		Application.Init();
		Glade.XML gxml = new Glade.XML("trv.glade", "mainWindow", null);
		gxml.Autoconnect(this);
		// code snip //
		Application.Run();
	}
	
	static void on_recipetree_row_activated(object o, RowActivatedArgs args)
	{
		Console.WriteLine("Row activated");
		TreeIter iter = new TreeIter();
		TreeModel m = recipetree.Model;
		m.GetIter(iter, args.Path);
		string col0 = m.GetValue(iter, 0);
		Console.WriteLine("Column Value: {0}", col0);
	}
}


Thanks,
Rob


More information about the Gtk-sharp-list mailing list