[Gtk-sharp-list] Troubleshooting with TreeView

Adam Tauno Williams adam at morrison-ind.com
Wed May 2 08:26:59 EDT 2007


On Wed, 2007-05-02 at 14:18 +0400, Oleg Ignatov wrote:
> Hello, All.
> How can I get index of the selected row in TreeView element?
> So I click on the row, and want to get index of selected item. How can
> I resolve this problem?

Using Selection.GetSelected

protected Task GetSelectedTask(TreeView _view)
{
  TreeIter        iter;
  TreeModel       model;
  TreeSelection   selection;
  Task            task;

  task = null;
  if(_view.Selection.GetSelected(out model, out iter))
    task = (model.GetValue (iter, 0) as Whitemice.ZOGI.Task);
  return task;
} /* End GetSelectedTask */

In the above example the treeview has a store of Task objects:
taskStore = new ListStore(typeof(Task));

What you get out of the TreeView of course depends on what you put in
it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20070502/9bc98ceb/attachment.bin 


More information about the Gtk-sharp-list mailing list