[Gtk-sharp-list] What's the best way to display fractions in a TreeView
Matjaž Mihelič
mlgs at arsis.net
Fri Jul 24 18:24:59 EDT 2009
On Fri, 2009-07-24 at 15:19 -0700, Slug wrote:
> I'm really having a lot of trouble figuring out how I should go about
> displaying a bunch of numeric values as fractions in a TreeView. If I
> convert them to strings and load them into the model, then the sorting is
> all out of order when I click on the column header. It looks like this
> (which is wrong):
> 1 1/4
> 11 1/2
> 2 3/4
>
use double or decimal as store value, use CellRendererText and then use
cell function
TreeViewColumn.SetCellDataFunc(CellRenderer,TreeCellDataFunc)
to calculate Text value;)
> Is there a delegate I can invoke in the TreeStore or on CellRendererText
> where I can stick the code that converts the raw numeric values in the model
> to the formatted strings that get displayed in the end? Or, do I have to
> create a subclass
> ( e.g. CellRendererFractionText : CellRendererText ) and then override the
> Render method. This seems like a huge hassle for something so common -
> especially because there are no simple examples on how to do this for just a
> simple little bit of read only text.
>
> I must be totally missing something big and obvious - what is it ?
>
> thx - Slugs
>
More information about the Gtk-sharp-list
mailing list