On Thu, 2010-08-26 at 12:25 +0200, Sebastian wrote: > Hey Guys, > I'm writing my first gtk# Application just for learning. It should be a > simple DVD Managment Tool. I implemented a Treeview that gets its > Columns, Titles and Values dynamic from an SQLite DB. That works so far. > What I now want is a possibility to edit the Records within the > Treeview > TreeViewColumn tvcol = new TreeViewColumn(); > CellRendererText tcellr = new CellRendererText(); > tcellr.BackgroundGdk = new Gdk.Color(220,220,220); > tvcol.Title = ""; > tvcol.PackStart(tcellr, true); > tvcol.AddAttribute(tcellr, "text", 0); > treeview.AppendColumn(tvcol); > for (Index = 0; Index < reader.FieldCount; Index++) //iterate through > each field of the database > { > FieldName = reader.GetName(Index); //get the query results field names > defined under strSQL > TreeViewColumn col = new TreeViewColumn(); // add columns for each > field > CellRendererText colr = new CellRendererText(); > colr.Editable = true; //Make every single Cell editable > colr.Edited += CellEdit; ... > col.AddAttribute(colr, "text", Index+1); > treeview.AppendColumn(col); //Add the Column to the Treeview > }
Why not public class BoundCellRendererText : CellRendererText { string fieldName; public BoundCellRendererText(string _fieldName) : CellRendererText() { this.fieldName = _fieldName } public string FieldName { get { return this.fieldName; } } } And use that in place of CellRendererText. BoundCellRendererText colr = new BoundCellRendererText(fieldname); colr.Editable = true; //Make every single Cell editable colr.Edited += CellEdit; ... treeview.AppendColumn(col); //Add the Column to the Treeview And then in the EditedHandler your "o" would be your BoundCellRendererText that knows about the field name. -- Adam Tauno Williams <awill...@whitemice.org> LPIC-1, Novell CLA <http://www.whitemiceconsulting.com> OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/gtk-sharp-list