[Gtk-sharp-list] Custom CellRenderer
Nicholas Frechette
zeno490 at gmail.com
Sun Jan 30 12:17:46 EST 2011
Hi,
I am attempting something similar to the following:
http://kapo-cpp.blogspot.com/2008/05/different-cellrenderers-on-same-column.html
To achieve the same behavior with gtk#, I created a proxy interface as he
does to expose the protected render method required. I then created a
version of each cell renderer that inherits the interface and the renderer
desired (ie: CellRendererComboProxy) that forwards all the calls to the base
class.
I then have a simple converter cell renderer that takes a key as a property
and forwards all the method calls to the proper cell renderer afterwards.
This appears to work fine for rendering static data. I can see the spin
button value, the checkbox marked, etc.
However, I cannot edit any of the values. The StartEditing function never
appears to be called, nor the Activate function.
I do set my cellrenderers to be activatable and editable but no luck. I even
attempted to override all the properties in cellrenderer in my converter to
forward the property calls to the correct cellrenderer without further luck.
I did run into the following problem though:
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.InvalidOperationException:
GLib.PropertyAttribute cannot be applied to property Mode of type
CellRendererConverter because the return type of the property is not
supported
at GLib.Object.AddProperties (GType gtype, System.Type t) [0x00000] in
<filename unknown>:0
at GLib.Object.RegisterGType (System.Type t) [0x00000] in <filename
unknown>:0
With the following code in my custom cell renderer:
[GLib.Property("mode")]
public new CellRendererMode Mode { get; set; } // Impl not shown, problem
still occurs without 'new' here
Strangely enough, the same code in the gtk# cellrenderer appears to work
fine.
Is there a better way to achieve a treeview in which I can display 2 columns
and edit values of various types in the second? (Much like a property grid)
Regards,
Nicholas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20110130/fcd1e536/attachment.html
More information about the Gtk-sharp-list
mailing list