Help with CellRenderSpin

View: New views
1 Messages — Rating Filter:   Alert me  

Help with CellRenderSpin

by alanb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I have a treeview with two columns. I want the  second column to use a spinbutton to edit and  display a float phase value between 0 and 360. Nothing is displayed in this column until I select a row and click on the column to initiate editing, then I see the spinbutton. However I want to see the spinbutton value when not editing and the spinbutton only when editing. Can someone tell me how to do this or at least have the spin visible at all times.

Thanks
Alan

The code I am using is

       Gtk.TreeViewColumn col2 = new Gtk.TreeViewColumn ();
        col2.Title = "Phase";
        Gtk.CellRendererSpin col2Cell = new Gtk.CellRendererSpin();
        col2Cell.Digits = 3;
        Adjustment adj = new Adjustment(0,0,360,0.1,10,10);
        col2Cell.Adjustment = adj;
        col2Cell.Editable = true;
        col2Cell.Visible = true;
        col2Cell.Sensitive = true;
                               
        col2.PackStart (col2Cell, true);
        col2.SetCellDataFunc (col2Cell, new Gtk.TreeCellDataFunc (RenderCol2));

private void RenderCol2 (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
        PhaseElement rp = (PhaseElement) model.GetValue (iter, 0);
        (cell as Gtk.CellRendererSpin).Adjustment.Value = rp.Phase;
}