package main
import (
"fmt"
"log"
"os"
"strings"
)
import (
"github/lxn/walk"
. "github/lxn/walk/declarative"
)
func main() {
mw := &MyMainWindow{model: NewEnvModel()}
if _, err := (MainWindow{
AssignTo: &mw.MainWindow,
Title: "Walk ListBox Example",
MinSize: Size{240, 320},
Size: Size{300, 400},
Layout: VBox{MarginsZero: true},
Children: []Widget{
HSplitter{
Children: []Widget{
ListBox{
AssignTo: &mw.lb,
Model: mw.model,
OnCurrentIndexChanged: mw.lb_CurrentIndexChanged, OnItemActivated: mw.lb_ItemActivated,
},
TextEdit{
AssignTo: &,
ReadOnly: true,
},
},
},
},
}.Run()); err != nil {
log.Fatal(err)
}
}
type MyMainWindow struct {
*walk.MainWindow
model *EnvModel
lb *walk.ListBox
te *walk.TextEdit
}
func (mw *MyMainWindow) lb_CurrentIndexChanged() {
i := mw.lb.CurrentIndex()
item := &del.items[i]
fmt.Println("CurrentIndex: ", i)
fmt.Println("CurrentEnvVarName: ", item.name)
}
func (mw *MyMainWindow) lb_ItemActivated() {
value := mw.model.items[mw.lb.CurrentIndex()].value
walk.MsgBox(mw, "Value", value, walk.MsgBoxIconInformation)
}
type EnvItem struct {
name string
value string
windows开发平台}
type EnvModel struct {
walk.ListModelBase
items []EnvItem
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论