[Gtk-sharp-list] Editing a TreeView?

Carlos Adriano Portes xcap2000 at gmail.com
Fri Oct 13 17:14:18 EDT 2006


Thank you, exactly what I need! :)

2006/10/13, Peter Johanson <latexer at gentoo.org>:
> On Thu, Oct 12, 2006 at 04:19:48PM -0300, Carlos Adriano Portes wrote:
> > Hi all
> >
> > I have created a TreeView with two columns "Id" and "Name", these
> > columns are a result of a database connection that returns a DataSet,
> > I would like to let the user change the name column and when finished
> > the column would take the new value, but it does not happen, what must
> > I do in order to get it working, an example of what I want is that
> > list in the application sound-suicer when importing cd's whe can edit
> > its information before doing the rip, thanks in advance.
>
> You need to use editable CellRenderers. So if you are packing a
> CellRendererText for displaying the name, you do something like:
>
> cell.Editable = true
> cell.Edited += delegate (object o, EditedArgs e) {
>         TreeIter iter;
>         if (model.GetIter (out iter, new TreePath (e.Path))) {
>                 model.SetValue (iter, 1, e.NewText);
>         }
> }
>
>
> If instead have some rich object you are storing in the TreeModel, and
> you're modifying some field on it, you'll need to call
> model.EmitRowChanged (iter, path); after updating it, to make sure the
> rendering of the given row is updated accordingly.
>
> -pete
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>


More information about the Gtk-sharp-list mailing list