[Gtk-sharp-list] How to display data from a SQLite database into a GTK# TreeView?

Christian Hoff Christian_Hoff at gmx.net
Fri Apr 29 11:11:26 EDT 2011


> http://www.mono-project.com/GtkSharp_TreeView_Tutorial. First I create the
> model (ListStore) by initializing it with the string type for the data of
> every column. Then I append the columns of the data table to the tree
> view.
> Then I engage the sqlite reader, and for every entry I add its data to the
> model. Then I add a cell for each column pointing to the data. Finally, I
> give the tree view its model.

The clean way would be to create your own TreeModel for the kind of data you are trying to read.

I have written a model for Sytem.Data.DataViews and generalized to it to take any type of list some time ago, and these are sufficient probably for most of all queries.

Using your own TreeModel causes a significant performance boost compared to copying the data in the beginning and is a more clean approach to the problem.

Simply use treeModel = new Gtk.TreeModelAdapter(new IListStore(mydataview)));
to make it work.

Maybe some day we can get this integrated into Gtk# trunk. I still think that IList support would be a valueable addition, but unfortunately I did not have the time to pursue this further.

You might also want to look at gtk-databind at http://gtk-databind.arsis.net/, but the project seems to be dead.

Unfortunately, I cannot help you with the specific error you are seeing with your code.

- Christian
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IListStore.cs
Type: text/x-csharp
Size: 11748 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20110429/ac986276/attachment-0001.bin 

More information about the Gtk-sharp-list mailing list