[Gtk-sharp-list] Decimals in CellRendererText
latexer at gentoo.org
Mon Aug 14 12:49:02 EDT 2006
On Mon, Aug 14, 2006 at 11:19:36AM +0200, Elmar Haneke wrote:
> I want to edit Values of type double within an Treeview. Therefore I did
> user CellRendererText class for Display.
> How can I control how many decimals are shown? Currentliy I get a lot of
> trailing "0" - I would prefer to see "1" instead of "1.000000".
In your TreeCellDataFunc callback used for rendering, you'll want to
use the decimal ToString overload which takes a string format parameter.
((CellRendererText)cell).Text = ((double)model.GetValue (iter, 0)).ToString ("#.##");
<latexer at gentoo.org>
More information about the Gtk-sharp-list