尝试在mono develop中制作表格

尝试在mono develop中制作表格,mono,Mono,我刚开始使用monodevelop,我很难设计表单。我已经理解了容器内小部件的概念。我正在尝试获取一个滚动视图中的表。该表应该有3列,我应该能够设置列名 我看过mono develop的一些文档,这些文档展示了如何使用节点视图来做同样的事情,但我还没有弄清楚为什么它会出现在一个新窗口中,以及如何在我的第一个屏幕上显示它。还有什么方法可以将它拖放到表单中以生成列和表头?我已附上代码: using System; using Gtk; namespace ImageCompressionTool {

我刚开始使用monodevelop,我很难设计表单。我已经理解了容器内小部件的概念。我正在尝试获取一个滚动视图中的表。该表应该有3列,我应该能够设置列名

我看过mono develop的一些文档,这些文档展示了如何使用节点视图来做同样的事情,但我还没有弄清楚为什么它会出现在一个新窗口中,以及如何在我的第一个屏幕上显示它。还有什么方法可以将它拖放到表单中以生成列和表头?我已附上代码:

using System;
using Gtk;
namespace ImageCompressionTool
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Application.Init ();
            MainWindow win = new MainWindow ();
            win.Show ();
            Application.Run ();

            Gtk.Application.Init ();
            NodeViewExample win1 = new NodeViewExample ();
            win1.Show ();
            Gtk.Application.Run ();

        }

    }
    public class MyTreeNode : Gtk.TreeNode {

        string song_title;

        public MyTreeNode (string artist, string song_title)
        {
            Artist = artist;
            this.song_title = song_title;
        }

        [Gtk.TreeNodeValue (Column=0)]
        public string Artist;

        [Gtk.TreeNodeValue (Column=1)]
        public string SongTitle {get { return song_title; } }

    }

    public class NodeViewExample : Gtk.Window {
        Gtk.NodeStore store;
        Gtk.NodeStore Store {
            get {
                if (store == null) {
                    store = new Gtk.NodeStore (typeof (MyTreeNode));
                    store.AddNode (new MyTreeNode ("The Beatles", "Yesterday"));
                    store.AddNode (new MyTreeNode ("Peter Gabriel", "In Your Eyes"));
                    store.AddNode (new MyTreeNode ("Rush", "Fly By Night"));
                }
                return store;
            }
        }

        public NodeViewExample () : base ("NodeView")
        {
            SetSizeRequest (200,150);

            // Create our TreeView and add it as our child widget
            Gtk.NodeView view = new Gtk.NodeView (Store);
            Add (view);

            // Create a column with title Artist and bind its renderer to model column 0
            view.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);

            // Create a column with title 'Song Title' and bind its renderer to model column 1
            view.AppendColumn ("Song Title", new Gtk.CellRendererText (), "text", 1);
            view.ShowAll ();
        }

    }


}

请帮帮我。谢谢

如果您只想显示NodeView窗口,请删除显示主窗口的代码。您的主方法当前显示两个窗口。如果您只想让它显示您的NodeView示例窗口,那么它应该如下所示:

    public static void Main (string[] args)
    {
        Gtk.Application.Init ();
        NodeViewExample win1 = new NodeViewExample ();
        win1.Show ();
        Gtk.Application.Run ();
    }

您不能将列拖放到设计器中的Gtk.NodeView或Gtk.TreeView中。

请提供您尝试的代码和得到的结果。上面的代码显示了两个窗口,首先它用我的GUI启动主窗口,当我试图关闭它时,它会弹出一个带有我的表的新窗口。