本文整理匯總了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{},
//.........這裏部分代碼省略.........