[Gtk-sharp-list] retrieving the values behind a selected row in a treeview

Jason Boutwell jason.boutwell@comcast.net
08 Sep 2003 12:55:39 -0400


TreeIter iter = new TreeIter();
TreeModel yourModel;
CustomObject yourValueObject = null;

if (yourTreeView.Selection.GetSelected(out yourModel, ref iter)) {
    GLib.Value treeValue = new GLib.Value();
    int invisibleCol = 1;
    yourModel.GetValue(iter, invisibleCol, out treeValue);
    yourValueObject = (CustomObject) treeValue.Val;



Works for me.


On Mon, 2003-09-08 at 16:17, Davy Brion wrote:
> Hey guys,
> i have a treeview, and one of the columns is invisible and contains a 
> reference to the original object that is represented in the other columns for 
> that row.  I'd like to be able to retrieve that reference when the user 
> clicks on one of the rows.
> But i need some help with this because the documentation isn't very helpful 
> (many methods don't have any explanations yet).  
> So could anyone tell me how i can retrieve the values that are stored in the 
> ListStore object that the TreeView is showing?
> I'm assuming i need to use the GetSelected method of a TreeSelection object, 
> and then try to access those values through the TreeIter object that i need 
> to pass along to the GetSelected method, but i'm a bit confused about how to 
> retrieve the values from that TreeIter...  the documenation lists the 
> user_data, user_data2 and user_data3 fields, but how do u know which one 
> corresponds to which column? What if u have more columns? Isn't there a 
> 'cleaner' way of retrieving those values? Or does it work differently from 
> the way i think it works?  If anyone could shed some light on this issue, i'd 
> very much appreciate it.
> thx,
> davy brion
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list