dotnet new console
dotnet add package GtkSharp
dotnet run
using Gtk; class Program { public static void Main() { Application.Init(); new FirstWindow(); Application.Run(); } public static void Quit() { Application.Quit(); } }
using Gtk; class FirstWindow : Window { public FirstWindow() : base("Test") { SetDefaultSize(600, 350); SetPosition(WindowPosition.Center); DeleteEvent += delegate { Program.Quit(); }; VBox vBox = new VBox(); Add(vBox); HBox hBox = new HBox(); vBox.PackStart(hBox, false, false, 5); TreeStore store = new TreeStore ( typeof(Gdk.Pixbuf), typeof(string), typeof(string) ); TreeView treeView = new TreeView(store); treeView.AppendColumn(new TreeViewColumn("", new CellRendererPixbuf(), "pixbuf", 0)); treeView.AppendColumn(new TreeViewColumn("Id", new CellRendererText(), "text", 1)); treeView.AppendColumn(new TreeViewColumn("Name", new CellRendererText() { Xpad = 4 }, "text", 2) { MinWidth = 20, Resizable = true, SortColumnId = 2 }); //Пустишка для заповнення вільного простору treeView.AppendColumn(new TreeViewColumn()); var img = new Gdk.Pixbuf("form.ico", 16, 16); TreeIter root = store.AppendValues(img, "0", "Root"); TreeIter node = store.AppendValues(root, img, "1", "Name A"); store.AppendValues(node, img, "2", "Name B"); store.AppendValues(node, img, "3", "Name C"); //Відкрити вітку treeView.ExpandToPath(store.GetPath(node)); hBox.PackStart(treeView, true, true, 5); ShowAll(); } }
© accounting.org.ua - 2024