25.07.2024 17:26 Gtk3
Приклад використання віджету FlowBox - розміщує дочірні віджети в сітці перекомпонування

dotnet new consoledotnet add package GtkSharpdotnet runusing 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, true, true, 5);
ScrolledWindow scroll = new ScrolledWindow();
scroll.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
hBox.PackStart(scroll, true, true, 5);
FlowBox flowBox = new FlowBox
{
Orientation = Orientation.Horizontal,
Valign = Align.Start,
MinChildrenPerLine = 2,
MaxChildrenPerLine = 5,
SelectionMode = SelectionMode.None
};
for (int i = 0; i < 23; i++)
flowBox.Add(new Button($"{i}"));
scroll.Add(flowBox);
ShowAll();
}
}© accounting.org.ua - 2025