[Gtk-sharp-list] Problems with custom treeview column
Matthew Beckler
mbeckler at wins-inc.com
Tue Jul 5 15:21:26 EDT 2005
Hello everyone,
I am trying to put a datetime into a liststore -> treeview. Eventually,
I would like to be able to enable sorting for that column, but first I
need it to work without sorting. I determined that I need to have a
custom tree cell data function that will take the datatime passed in and
extract the date in the proper format, and set the cell's text property
to that date. Here is that function:
public static void dateColumnFunction (Gtk.TreeViewColumn tree_column,
Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter)
{
DateTime dt = (DateTime) tree_model.GetValue (iter, 2);
((CellRendererText) cell).Text = dt.ToShortDateString();
}
My problem is in assigning that tree cell data func. to the column. When
I use the following line to create and append the column to the
treeview, everything works as I would like it to, ie. the text is
properly displayed in the datetime column.
//this one works:
treeview.AppendColumn("Date Of Birth", new CellRendererText(), new
TreeCellDataFunc(dateColumnFunction));
//I think this one should work as well, but it isn't:
TreeViewColumn tvc = new TreeViewColumn();
tvc.Title = "Date Of Birth";
tvc.SetCellDataFunc(new CellRendererText(), new
TreeCellDataFunc(dateColumnFunction));
treeview.AppendColumn(tvc);
If anybody knows of a good tutorial on how to do this sort of thing
properly, I would appreciate that as well.
Also, as I mentioned before, eventually I would like to be able to sort
by this column, probably needing a custom cell sorter function? Any help
or direction will be greatly appreciated.
Thanks in advance,
Matthew
More information about the Gtk-sharp-list
mailing list