[Gtk-sharp-list] TreeStore saving state
Christian Hoff
christian_hoff at gmx.net
Sun Aug 3 10:57:36 EDT 2008
A small example (note that this will only work with Gtk# 2.12):
System.Data.DataTable table = new System.Data.DataTable ();
table.Columns.Add ("ID", typeof (int)).Unique = true;
table.Columns.Add ("Name", typeof (string));
table.Rows.Add (0, "Winston Churchill");
table.Rows.Add (1, "Angela Merkel");
// Create a new DataView and sort the data somehow
System.Data.DataView view = new System.Data.DataView (table, "ID > '0'",
"ID ASC", System.Data.DataViewRowState.CurrentRows);
DataViewStore store = new DataViewStore (view);
Gtk.TreeView TestView = new Gtk.TreeView (store.Adapter);
// SHowing only name and not ID, showing the ID will a little more
difficult / cannot be done via attribute mappings; you will have to use
a CellDataFunc for this purpose
TestView.Columns.Add ("Name", new Gtk.CellrendererText (), "text", 1);
Haven't tested this myself, but I hope it will help you...
Christian
> Thanks,
> Very interesting idea, I have quite a little experience in overloading
> and sub-classing using C# I try to use object in the framework unless
> there is no good way to do it using the base framework. Do you think
> you could share a usage example so I can get a better of what you have
> in mind. I think I know where your headed but I'm not quite sure.
>
> The more I think about it the more I like your idea, once you bridge
> the gap between TreeStore and DataTable managing the database and sql
> will fall right into place.
>
> Still I would be interested to hear what other ideas are out there
> while I'm playing with your class, errr working with your class.
>
> Thanks
> Andy
More information about the Gtk-sharp-list
mailing list