[Gtk-sharp-list] Getting the selected item from a treeview?

Gonzalo Paniagua Javier gonzalo@ximian.com
25 Apr 2003 16:27:41 +0200


El vie, 25 de 04 de 2003 a las 15:33, Charles-Louis escribió:
> Hello,
> 
> I have constructed a TreeView with glade, for use in my program. I
> have added some eventhandlers for the RowChanged and RowActivated in
> the properties window of the TreeView, but I wanted to know how to
> display the selected element in, say, the statusbar.
> 
[...]

You're not using current CVS, are you?

Because this signature:
> public void OnTreeview1RowActivated(object o, EventArgs args)

is now:
public void OnTreeView1RowActivated (object o, RowActivatedArgs args)

Apart from this, you can get the 'activated' value with something like:

> {
> label1.Text = "Toto";
> statusbar1.Pop(1);
> statusbar1.Pop(0);
  TreeView tv = (TreeView) o;
  TreeModel model = tv.Model;
  TreeIter iter;
  model.GetIter (out iter, args.Path);
  GLib.Value val;
  model.GetValue (iter, 0, out value);
  statusbar1.Push(0,"Selection made: " + (string) value);

> }

-Gonzalo