В одній колонці розміщено два значення.
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); ListStore store = new ListStore ( typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(int), typeof(string) ); TreeView treeView = new TreeView(store); treeView.AppendColumn(new TreeViewColumn("", new CellRendererPixbuf(), "pixbuf", 0)); treeView.AppendColumn(new TreeViewColumn("Id", new CellRendererText(), "text", 1)); { TreeViewColumn treeViewColumn = new TreeViewColumn() { Title = "Name / Count", MinWidth = 20, Resizable = true, SortColumnId = 2 }; CellRendererText cellA = new CellRendererText() { Xpad = 4 }; treeViewColumn.PackStart(cellA, true); treeViewColumn.AddAttribute(cellA, "text", 2); CellRendererText cellB = new CellRendererText() { Xpad = 4 }; treeViewColumn.PackEnd(cellB, false); treeViewColumn.AddAttribute(cellB, "text", 3); treeView.AppendColumn(treeViewColumn); } treeView.AppendColumn(new TreeViewColumn("Desc", new CellRendererText(), "text", 4)); //Пустишка для заповнення вільного простору treeView.AppendColumn(new TreeViewColumn()); var img = new Gdk.Pixbuf("form.ico", 16, 16); store.AppendValues(img, "1", "Name A", 211, "Text text"); store.AppendValues(img, "2", "Name B text text", 411, "Text text"); store.AppendValues(img, "3", "Name C", 311, "Text text"); store.AppendValues(img, "4", "Name D", 511, "Text text"); store.AppendValues(img, "5", "Name E", 111, "Text text"); hBox.PackStart(treeView, true, true, 5); ShowAll(); } }
© accounting.org.ua - 2024