[Mono-list] [ASK] NodeStore filter

dedi mdedirudianto at gmail.com
Fri Jul 10 22:26:33 EDT 2009


Dear Mono masters,

I am newbie gtk# programmer, migrating from winform.
Is there any way to filter the content of NodeView instead using
TreeModelFilter?
Since I'm using TreeNode to make it easier to hook.
Here is the code sample:

[TreeNode (ListOnly=true)]
class Employee : TreeNode
{
	[TreeNodeValue (Column=0)]
	public string Name;
	
	[TreeNodeValue (Column=1)]
	public string Address;
	
	public Employee (string name, string address)
	{
		Name = name;
		Address = address;
	}
}

It's very easy to hook to the NodeView

Gtk.NodeView view = new Gtk.NodeView ();
view.NodeStore = PopulateStore (); // generate list of employee

But, if I'm using TreeModelFilter, I should use TreeStore instead of TreeNode.

TreeStore ts = new TreeStore (typeof (Employee));
// add something to treestore...
Gtk.TreeModelFilter filter = new Gtk.TreeModelFilter (ts, null);
view.Model = filter;

And it was cumbersome to set SetCellDataFunc on each cell to show the value,
since there are a lot of fields will be used.

nameColumn.SetCellDataFunc (nameCell, new Gtk.TreeCellDataFunc (RenderName));
addressColumn.SetCellDataFunc (addressCell, new Gtk.TreeCellDataFunc
(RenderAddress));
// and others

Is there any way to use TreeModelFilter with custom TreeNode?
Or I missed something. CMIIW. Thank you very much.

Regards,
dedi


More information about the Mono-list mailing list