In order to data bind a DataTable to a Gtk.TreeView using a ListStore treee model without referencing System.Data, you would using the System.ComponentModel interfaces that DataTable implements.
Both the DataGrid in System.Web and System.Windows.Forms use the interfaces from Sysstem.ComponentModel for data binding purposes. You can use ideas from the method DataBind() in DataGrid.cs in sqlsharpgtk: http://anonsvn.mono-project.com/viewvc/trunk/sqlsharpgtk/sqlsharpgtk/DataGrid.cs?revision=70316&view=markup It uses the GetResolvedDataSource that was borrowed from mono's System.Web implementation. It shows you various interfaces it uses to load the DataTable, such as, IListSource IList IEnumerable ITypedList ICustomTypeDescriptor And some classes: PropertyDescriptorCollection PropertyDescriptor DataTable implements IListSource. The DataGrid looks for an IListSource, if found, calls GetList() on it to return an IList. For a DataTable, this IList is a DataView. IList.ContainsListCollection returns false. Then GetItemProperties is called on the DataView to return a PropertyDescriptorCollection. The concrete classes in this collection are: DataColumnPropertyDescriptor - describes a DataColumn in a DataRowView DataRelationPropertyDescriptor - describes a DataRelation In order to get each row, you would get an IEnumerable from the DataView. This IEnumerable is an enumerator of DataRowsViews. >From each DataRowView, get the ICustomTypeDescriptor. From there, call >GetProperties to get another PropertyDescriptorCollection. Each property >descriptor describes a field. So, call GetValue. System.Windows.Forms does things differently. --- On Wed, 7/23/08, Mike Kestner <[EMAIL PROTECTED]> wrote: > From: Mike Kestner <[EMAIL PROTECTED]> > Subject: Re: [Gtk-sharp-list] Data grid comparable to the data grid control > in MS/VS > To: "Christian Hoff" <[EMAIL PROTECTED]> > Cc: gtk-sharp-list@lists.ximian.com > Date: Wednesday, July 23, 2008, 9:12 AM > On Tue, 2008-07-22 at 07:59 +0200, Christian Hoff wrote: > > I have written a custom TreeModel to display > DataTables. With this one > > it should be easy to display a DataTable in a > Gtk.TreeView or any other > > widget you want. Maybe it's even compatible with > the Medsphere widget. > > However, I had to make use of GInterface > implementation which is only > > supported in Gtk# 2.12 (see > > http://www.mono-project.com/ImplementingGInterfaces) > > > > Mike, how about adding a custom tree model to display > DataTables to > > Gtk.DotNet? I think this could really be a useful > feature since Gtk# > > completly lacks support for DataTables. I would > volunteer to start > > working on it if you want. > > There have been several efforts toward a > "data-bound" tree model over > the years. The archives should have links to fairly recent > efforts to > provide databinding for the entire toolkit. > > I would be more interested in including such a data binding > than a tree > model specifically written for DataTable. Although I also > think such a > project could easily stand on its own, and might be easier > to integrate > into applications than a Gtk# 2.next dependency. > > Mike > > _______________________________________________ > Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/gtk-sharp-list _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/gtk-sharp-list