本文整理汇总了Golang中github.com/lxn/walk.TableView.CurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:Golang TableView.CurrentIndex方法的具体用法?Golang TableView.CurrentIndex怎么用?Golang TableView.CurrentIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxn/walk.TableView
的用法示例。
在下文中一共展示了TableView.CurrentIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var mainWindow *walk.MainWindow
var treeView *walk.TreeView
var tableView *walk.TableView
var webView *walk.WebView
treeModel, err := NewDirectoryTreeModel()
if err != nil {
log.Fatal(err)
}
tableModel := NewFileInfoModel()
if err := (MainWindow{
AssignTo: &mainWindow,
Title: "Walk File Browser Example",
MinSize: Size{600, 400},
Size: Size{800, 600},
Layout: HBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
TreeView{
AssignTo: &treeView,
Model: treeModel,
OnCurrentItemChanged: func() {
dir := treeView.CurrentItem().(*Directory)
if err := tableModel.SetDirPath(dir.Path()); err != nil {
walk.MsgBox(
mainWindow,
"Error",
err.Error(),
walk.MsgBoxOK|walk.MsgBoxIconError)
}
},
},
TableView{
AssignTo: &tableView,
Columns: []TableViewColumn{
TableViewColumn{
Title: "Name",
DataMember: "Name",
Width: 200,
},
TableViewColumn{
Title: "Size",
DataMember: "Size",
Format: "%d",
Alignment: AlignFar,
Width: 80,
},
TableViewColumn{
Title: "Modified",
DataMember: "Modified",
Format: "2006-01-02 15:04:05",
Width: 120,
},
},
Model: tableModel,
OnCurrentIndexChanged: func() {
var url string
if index := tableView.CurrentIndex(); index > -1 {
name := tableModel.items[index].Name
dir := treeView.CurrentItem().(*Directory)
url = filepath.Join(dir.Path(), name)
}
webView.SetURL(url)
},
},
WebView{
AssignTo: &webView,
},
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
mainWindow.Run()
}
示例2: main
func main() {
font := Font{
Family: "Times New Roman",
PointSize: 13,
Bold: true,
}
usr, _ := user.Current()
usrModel := env.NewModel(0)
sysModel := env.NewModel(1)
var usrTableView, sysTableView *walk.TableView
var mw *walk.MainWindow
MainWindow{
Title: "Enviroment Variable",
Size: Size{600, 700},
Layout: VBox{},
AssignTo: &mw,
Font: font,
Children: []Widget{
VSplitter{
Children: []Widget{
GroupBox{
Title: "User variables for " + usr.Username,
Font: font,
Layout: VBox{},
Children: []Widget{
TableView{
AssignTo: &usrTableView,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "name", Width: 200},
{Title: "value"},
},
LastColumnStretched: true,
Model: usrModel,
OnItemActivated: func() {
index := usrTableView.CurrentIndex()
if index != -1 {
EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
}
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
Text: "New...",
OnClicked: func() {
NewVariable(mw, usrModel)
},
},
PushButton{
Text: "Edit...",
OnClicked: func() {
index := usrTableView.CurrentIndex()
if index != -1 {
EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
}
},
},
PushButton{
Text: "Delete",
OnClicked: func() {
index := usrTableView.CurrentIndex()
if index != -1 {
DeleteVariable(mw, usrModel, usrModel.GetVariable(index).Name)
}
},
},
},
},
},
},
GroupBox{
Title: "System variables",
Font: font,
Layout: VBox{},
Children: []Widget{
TableView{
AssignTo: &sysTableView,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "Variable", Width: 200},
{Title: "Value"},
},
LastColumnStretched: true,
Model: sysModel,
OnItemActivated: func() {
index := sysTableView.CurrentIndex()
if index != -1 {
EditVariable(mw, sysModel, sysModel.GetVariable(index).Name, sysModel.GetVariable(index).Value)
}
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
//.........这里部分代码省略.........