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.
Thanks,
Philip
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);
Window.Add(Container);
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);
Container.ShowAll();
Window.ShowAll
();
ShowTreeInfo("Main");
} catch (Exception ex)
{
Console.WriteLine(ex.Message);
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",
1);
tree.AppendColumn("Fruit", new
Gtk.CellRendererText(), "text", 2);
for (int i = 0; i < 40;
i++)
{
berichtListStore.AppendValues(i.ToString(),"Rupert", "Yellow
bananas");
}
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.Remove(Container.Children[3]);
Container.PackStart(tree, true, true,
0);
Container.ShowAll();
ShowTreeInfo("btnRefresh_Clicked");
}
void btn_ScrollUp(object sender, EventArgs
e)
{
ShowTreeInfo("before
btn_ScrollUp");
if
((tree.Vadjustment.Value - tree.Vadjustment.PageIncrement) >
tree.Vadjustment.Lower)
tree.Vadjustment.Value -=
tree.Vadjustment.PageIncrement;
else
{
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.Upper)
tree.Vadjustment.Value += tree.Vadjustment.PageIncrement;
}
}
_______________________________________________
Gtk-sharp-list maillist -
Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list