[Gtk-sharp-list] Editing a TreeView?
Peter Johanson
latexer at gentoo.org
Fri Oct 13 12:59:09 EDT 2006
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
More information about the Gtk-sharp-list
mailing list