[Gtk-sharp-list] TreeView Selection

Met met@uberstats.com
Wed, 07 Apr 2004 00:20:41 -0400


Hello,

On Wed, 2004-04-07 at 00:10, John Luke wrote:
> On Tue, 2004-04-06 at 00:18 -0400, Met wrote:
> > >From a curser changed event, how do I get the selected row?  I'd imagine
> > I would get an index which would let me search through the
> > TreeView.Model, but I cannot find examples, and the generated code is
> > driving me crazy.
> > 
> > Thanks in advance,
> > 
> something like this:
> TreeView tv = new TreeView ();
> tv.Selection.Changed += new EventHandler (OnSelectionChanged);
> 
> void OnSelectionChanged (object o, EventArgs args)
> {
> 	TreeModel model;
> 	TreeIter iter;
> 	string selected = "no selection";
> 
> 	// you get the iter and the model if something is selected
> 	if (tv.Selection.GetSelected (out model, out iter)
> 		selected = (string) model.GetValue (iter, column);
> 
> 	Console.WriteLine (selected);
> }
> 

Perfect, thanks a lot.