forked from ying32/govcl
/
main.go
72 lines (58 loc) · 1.57 KB
/
main.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
_ "github.com/ying32/govcl/pkgs/winappres"
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
)
type TMainForm struct {
*vcl.TForm
}
var mainForm *TMainForm
func (f *TMainForm) OnFormCreate(object vcl.IObject) {
f.SetCaption("TCheckListBox测试")
f.ScreenCenter()
chkListBox := vcl.NewCheckListBox(f)
chkListBox.SetParent(f)
chkListBox.SetAlign(types.AlClient)
chkListBox.SetOnClickCheck(func(sender vcl.IObject) {
fmt.Println("check单击。")
})
for i := 1; i < 100; i++ {
chkListBox.Items().Add(fmt.Sprintf("第%d个项目", i))
}
button := vcl.NewButton(f)
button.SetParent(f)
button.SetAlign(types.AlBottom)
button.SetCaption("项目启用")
button.SetOnClick(func(sender vcl.IObject) {
//fmt.Println("选中数:", chkListBox.Checked())
chkListBox.SetItemEnabled(0, !chkListBox.ItemEnabled(0))
})
// 获取/设置项目启用
//chkListBox.SetItemEnabled()
//chkListBox.ItemEnabled()
// 获取/设置项目状态
//chkListBox.State()
//chkListBox.SetState()
// 获取/设置项目选中
//chkListBox.Checked()
//chkListBox.SetChecked()
button = vcl.NewButton(f)
button.SetParent(f)
button.SetCaption("全选")
button.SetAlign(types.AlBottom)
button.SetOnClick(func(sender vcl.IObject) {
chkListBox.CheckAll(types.CbChecked, true, true)
})
button = vcl.NewButton(f)
button.SetParent(f)
button.SetCaption("取消全选")
button.SetAlign(types.AlBottom)
button.SetOnClick(func(sender vcl.IObject) {
chkListBox.CheckAll(types.CbUnchecked, true, true)
})
}
func main() {
vcl.RunApp(&mainForm)
}