[Gtk-sharp-list] TreeView.Vadjustment.PageSize not updated

Philip Wobst philip.wobst at aastra.com
Fri Jun 26 06:06:13 EDT 2009

Hi all,
in my application the user can load different treeviews - since the
application runs on a touchscreen I do not want to use scrollbars and
have page-up and page-down buttons instead. However, all data regarding
the Vadjustment is not updated when I load the treeview. When I do
select the page-down button the information is available for scrolling.
I have created a sample app with the same behaviour. The first table is
loaded into the VBox and the Vadjustment information is shown -
navigation via the scroll up and down button is possible and shows the
Vadjustment information before the scroll event. When the table is
refreshed using the Refresh table button no Vadjustment information is
available any more. However, if you now select the scroll down button
the information is available!?
Is there something I forgot after refreshing? 
I am using Mono 2.4 and have tested on Windows and Linux.
This is the code:
using System;
public class TreeViewExample
    // Gtk objects
    Gtk.Window Window;
    Gtk.VBox Container;
    Gtk.TreeView tree;
 public static void Main ()
  Gtk.Application.Init ();
  new TreeViewExample ();
  Gtk.Application.Run ();
 public TreeViewExample ()
    try {
        Window = new Gtk.Window ("TreeView Example");
        Window.SetSizeRequest (800,400);
        Container = new Gtk.VBox(false, 0);
        Gtk.Button btnDwon = new Gtk.Button("Scroll down");
        btnDwon.Clicked += new EventHandler(btn_ScrollDown);
        Container.PackStart(btnDwon, false, true, 2);
        Gtk.Button btnUp = new Gtk.Button("Scroll up");
        btnUp.Clicked += new EventHandler(btn_ScrollUp);
        Container.PackStart(btnUp, false, true, 2);
        Gtk.Button btnRefresh = new Gtk.Button("Refresh Table");
        btnRefresh.Clicked += new EventHandler(btnRefresh_Clicked);
        Container.PackStart(btnRefresh, false, true, 2);
        tree = GetTree();
        Container.PackStart(tree, true, true, 0);
        Window.ShowAll ();
    } catch (Exception ex) {
        throw ex;
    Gtk.TreeView GetTree()
        Gtk.TreeView tree = new Gtk.TreeView();
        Gtk.ListStore berichtListStore = new
Gtk.ListStore(typeof(string), typeof(string), typeof(string));
        tree.AppendColumn("#", new Gtk.CellRendererText(), "text", 0);
        tree.AppendColumn("Name", new Gtk.CellRendererText(), "text",
        tree.AppendColumn("Fruit", new Gtk.CellRendererText(), "text",
        for (int i = 0; i < 40; i++)
            berichtListStore.AppendValues(i.ToString(),"Rupert", "Yellow
        tree.Model = berichtListStore;
        return tree;
    void ShowTreeInfo(string msg)
        Gtk.Adjustment adj = tree.Vadjustment;
        Console.WriteLine("Message: {0}\n\t adj.PageSize:\t\t{1}\n\t
adj.Value:\t\t{2}\n\t adj.PageIncrement:\t{3}\n\t adj.Upper:\t\t{4}"
                , msg, adj.PageSize.ToString(), adj.Value.ToString(),
adj.PageIncrement.ToString(), adj.Upper.ToString());
    void btnRefresh_Clicked(object sender, EventArgs e)
        tree = GetTree();
        Container.PackStart(tree, true, true, 0);
    void btn_ScrollUp(object sender, EventArgs e)
        ShowTreeInfo("before btn_ScrollUp");
        if ((tree.Vadjustment.Value - tree.Vadjustment.PageIncrement) >
            tree.Vadjustment.Value -= tree.Vadjustment.PageIncrement;
            tree.Vadjustment.Value = tree.Vadjustment.Lower;
    void btn_ScrollDown(object sender, EventArgs e)
        ShowTreeInfo("before btn_ScrollDown");        
        if ((tree.Vadjustment.Value + tree.Vadjustment.PageIncrement) <
            tree.Vadjustment.Value += tree.Vadjustment.PageIncrement;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20090626/e4ca7fdb/attachment.html 

More information about the Gtk-sharp-list mailing list