我正在使用 monodevelop 创建一个系统。我需要实现 Gtk TreeView 来显示数据。我已经按照此处的说明进行操作,但仍然无法正常工作。
我的问题是我正在课堂上生成我的树视图。这是我的代码:
在 MainWindow.cs
protected void OnShowCustomerTab (object sender, System.EventArgs e)
{
customer.treeViewTable(customerTreeView);
}
在我的课上
public void treeViewTable(Gtk.TreeView tree)
{
tree = new Gtk.TreeView();
tree.Hide();
// generate tree column
Gtk.TreeViewColumn lineNoColumn = new Gtk.TreeViewColumn();
Gtk.CellRendererText lineNoCell = new Gtk.CellRendererText();
lineNoColumn.Title = "#";
lineNoColumn.PackStart(lineNoCell, true);
lineNoColumn.AddAttribute(lineNoCell, "text", 0);
Gtk.TreeViewColumn customerCodeColumn = new Gtk.TreeViewColumn();
Gtk.CellRendererText customerCodeCell = new Gtk.CellRendererText();
customerCodeColumn.Title = "Customer Code";
customerCodeColumn.PackStart(customerCodeCell, true);
customerCodeColumn.AddAttribute(customerCodeCell, "text", 1);
// append the column and data on the tree table
tree.AppendColumn(lineNoColumn);
tree.AppendColumn(customerCodeColumn);
tree.Show();
}
我的代码有问题吗?请帮忙。提前致谢。