-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwinforms.fsx
More file actions
40 lines (31 loc) · 996 Bytes
/
winforms.fsx
File metadata and controls
40 lines (31 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#r "System.Windows.Forms"
open System
open System.Drawing
open System.Windows.Forms
// Create the main form
let form = new Form(Text = "Counter Example", Width = 300, Height = 200)
// Counter state
let mutable count = 0
// Create UI elements
let counterLabel =
new Label(
Text = count.ToString(),
Font = new Font("Arial", 24.0f),
Dock = DockStyle.Top,
TextAlign = ContentAlignment.MiddleCenter
)
let incrementButton = new Button(Text = "+", Dock = DockStyle.Bottom)
let decrementButton = new Button(Text = "-", Dock = DockStyle.Bottom)
// Add event handlers for buttons
incrementButton.Click.Add(fun _ ->
count <- count + 1
counterLabel.Text <- count.ToString())
decrementButton.Click.Add(fun _ ->
count <- count - 1
counterLabel.Text <- count.ToString())
// Add controls to the form
form.Controls.Add(counterLabel)
form.Controls.Add(incrementButton)
form.Controls.Add(decrementButton)
// Run the application
Application.Run(form)