[Gtk-sharp-list] Getting the string of the selected item of a TreeView

Mike Kestner mkestner at gmail.com
Tue Jul 21 15:01:17 EDT 2009


On Tue, 2009-07-21 at 14:38 -0400, Ronaldo Nascimento wrote:
> I am trying to get the text of an item in a TreeView. The sample code
> provides the following:
> 
>      static void OnCursorChanged(object obj, EventArgs e)
>      {
>           TreeSelection selection = (obj as TreeView).Selection;
> 
>           TreeModel model;
>           TreeIter iter;
> 
>           // The iter will point to the selected row
>           if(selection.GetSelected(out model, out iter))
>           	Console.WriteLine("Path of selected row = {0}",
> model.GetPath(iter));

		Console.WriteLine (model.GetValue (iter, 0));

Assuming you stored the string you want to print in column 0 of the
model.




More information about the Gtk-sharp-list mailing list