25.07.2024 17:45 Gtk3
Приклад використання віджету ScrolledWindow - прокрутка вмісту

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() { ShadowType = ShadowType.In };
scroll.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
hBox.PackStart(scroll, true, true, 5);
VBox vBoxScroll = new VBox();
scroll.Add(vBoxScroll);
for (int i = 1; i < 15; i++)
{
HBox hBoxScroll = new HBox();
vBoxScroll.PackStart(hBoxScroll, false, false, 5);
hBoxScroll.PackStart(new Button($"Button {i}"), false, false, 5);
}
ShowAll();
}
}© accounting.org.ua - 2025