/// <summary> /// called when a cell was edited ... sets the data for the virtualgridcell and the model in the gtk tree store /// </summary> /// <param name="o"></param> /// <param name="args"></param> void cell_Edited(object o, Gtk.EditedArgs args) { TreeListCellRendererText cell = o as TreeListCellRendererText; if (cell != null) { Gtk.TreeIter iter; Tree.Model.GetIter(out iter, new Gtk.TreePath(args.Path)); VirtualGridRow row = getGridRow(iter); if (row != null) { row.setData(cell.ColumnName, args.NewText, true); Tree.Model.SetValue(iter, cell.ColumnIndex, args.NewText); if (AfterEdit != null) { AfterEdit(this, new RowChangedEventArgs(row, cell.ColumnName)); } } } }
public void reloadColumns() { int i=0; columns = new ArrayList(HeaderColumns.Count); List<EditableColumn> editablecolums = new List<EditableColumn>(10); foreach (VirtualGridHeaderColumn c in getHeaderColumns()) { Gtk.TreeViewColumn column = new Gtk.TreeViewColumn(); column.Visible = c.Visible; column.Title = c.ColumnName; column.Resizable = true; Gtk.CellRenderer cell; TreeListCellRendererText treecellrenderer = null; //DL rempixbuf // if (c.CustomOption.Equals("pixbuf", StringComparison.OrdinalIgnoreCase)) // { // cell = new Gtk.CellRendererPixbuf (); // } if (!String.IsNullOrEmpty(c.Renderer)) { Type tp = Type.GetType(c.Renderer); cell = (Gtk.CellRenderer)Sharpend.Utils.Reflection.createInstance(tp); } else { treecellrenderer = new TreeListCellRendererText(c.ColumnName, i); cell = treecellrenderer; } columns.Add(cell); column.PackStart(cell, true); Tree.AppendColumn(column); String attribute = "text"; //DL rempixbuf // if (c.CustomOption.Equals("pixbuf", StringComparison.OrdinalIgnoreCase)) // { // attribute = "pixbuf"; // } if (cell is Gtk.CellRendererPixbuf) { attribute = "pixbuf"; } if (OnTreeCellData != null) { column.SetCellDataFunc(treecellrenderer, OnTreeCellData); } column.AddAttribute(cell, attribute, i); if (cell is Gtk.CellRendererToggle) { (cell as Gtk.CellRendererToggle).Toggled += HandleToggled; (cell as Gtk.CellRendererToggle).Activatable = true; (cell as Gtk.CellRendererToggle).Mode = Gtk.CellRendererMode.Activatable; column.AddAttribute(cell,"active",i); } if ((treecellrenderer != null) && (c.Editable)) { if (String.IsNullOrEmpty(c.EditableColumn)) { treecellrenderer.Editable = true; } else { editablecolums.Add(new EditableColumn{ColumnName=c.EditableColumn, Cellrenderer = treecellrenderer,Column = column}); } treecellrenderer.Edited += new Gtk.EditedHandler(cell_Edited); treecellrenderer.EditingStarted += HandleTreecellrendererEditingStarted; } i++; } foreach(EditableColumn c in editablecolums) { int idx = getColumnIndex(c.ColumnName); c.Column.AddAttribute(c.Cellrenderer,"editable",idx); } }
public void reloadColumns() { int i = 0; columns = new ArrayList(HeaderColumns.Count); List <EditableColumn> editablecolums = new List <EditableColumn>(10); foreach (VirtualGridHeaderColumn c in getHeaderColumns()) { Gtk.TreeViewColumn column = new Gtk.TreeViewColumn(); column.Visible = c.Visible; column.Title = c.ColumnName; column.Resizable = true; Gtk.CellRenderer cell; TreeListCellRendererText treecellrenderer = null; //DL rempixbuf // if (c.CustomOption.Equals("pixbuf", StringComparison.OrdinalIgnoreCase)) // { // cell = new Gtk.CellRendererPixbuf (); // } if (!String.IsNullOrEmpty(c.Renderer)) { Type tp = Type.GetType(c.Renderer); cell = (Gtk.CellRenderer)Sharpend.Utils.Reflection.createInstance(tp); } else { treecellrenderer = new TreeListCellRendererText(c.ColumnName, i); cell = treecellrenderer; } columns.Add(cell); column.PackStart(cell, true); Tree.AppendColumn(column); String attribute = "text"; //DL rempixbuf // if (c.CustomOption.Equals("pixbuf", StringComparison.OrdinalIgnoreCase)) // { // attribute = "pixbuf"; // } if (cell is Gtk.CellRendererPixbuf) { attribute = "pixbuf"; } if (OnTreeCellData != null) { column.SetCellDataFunc(treecellrenderer, OnTreeCellData); } column.AddAttribute(cell, attribute, i); if (cell is Gtk.CellRendererToggle) { (cell as Gtk.CellRendererToggle).Toggled += HandleToggled; (cell as Gtk.CellRendererToggle).Activatable = true; (cell as Gtk.CellRendererToggle).Mode = Gtk.CellRendererMode.Activatable; column.AddAttribute(cell, "active", i); } if ((treecellrenderer != null) && (c.Editable)) { if (String.IsNullOrEmpty(c.EditableColumn)) { treecellrenderer.Editable = true; } else { editablecolums.Add(new EditableColumn { ColumnName = c.EditableColumn, Cellrenderer = treecellrenderer, Column = column }); } treecellrenderer.Edited += new Gtk.EditedHandler(cell_Edited); treecellrenderer.EditingStarted += HandleTreecellrendererEditingStarted; } i++; } foreach (EditableColumn c in editablecolums) { int idx = getColumnIndex(c.ColumnName); c.Column.AddAttribute(c.Cellrenderer, "editable", idx); } }