本文整理匯總了Golang中github.com/lxn/walk.TableView.SelectedIndexes方法的典型用法代碼示例。如果您正苦於以下問題:Golang TableView.SelectedIndexes方法的具體用法?Golang TableView.SelectedIndexes怎麽用?Golang TableView.SelectedIndexes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxn/walk.TableView
的用法示例。
在下文中一共展示了TableView.SelectedIndexes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateProj_Query
/**
** 查看所有項目的方法
**/
func CreateProj_Query(owner walk.Form) {
var dlg *walk.Dialog
var tv *walk.TableView
var dialog = Dialog{}
model := xorm.NewProjectModel()
dialog.AssignTo = &dlg
dialog.Title = "項目管理"
dialog.Layout = VBox{}
dialog.MinSize = Size{650, 300}
dialog.Children = []Widget{
TableView{
AssignTo: &tv,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "編號", Width: 50},
{Title: "名稱"},
{Title: "創建者"},
{Title: "創建時間", Format: "2006-01-02 15:04:05", Width: 130},
{Title: "描述", Width: 200},
},
Model: model,
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
Text: "創建",
OnClicked: func() {
CreateProj_Triggered(owner, model)
},
},
PushButton{
Text: "刪除",
OnClicked: func() {
indexs := tv.SelectedIndexes()
if indexs.Len() == 0 {
walk.MsgBox(owner, "提示", "請選擇要刪除的數據", walk.MsgBoxIconError)
return
}
walk.MsgBox(owner, "提示", "確認是否刪除此工程", walk.MsgBoxOKCancel)
obj := model.GetItemByindex(int64(indexs.At(0)))
xorm.DeleteProjectByObj(obj)
model.ResetRows()
},
},
},
},
}
dialog.Run(owner)
}
示例2: main
func main() {
rand.Seed(time.Now().UnixNano())
model := NewFooModel()
var tv *walk.TableView
MainWindow{
Title: "Walk TableView Example",
Size: Size{800, 600},
Layout: VBox{MarginsZero: true},
Children: []Widget{
PushButton{
Text: "Reset Rows",
OnClicked: model.ResetRows,
},
PushButton{
Text: "Select first 5 even Rows",
OnClicked: func() {
tv.SetSelectedIndexes([]int{0, 2, 4, 6, 8})
},
},
TableView{
AssignTo: &tv,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
MultiSelection: true,
Columns: []TableViewColumn{
{Title: "#"},
{Title: "Bar"},
{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
},
Model: model,
OnSelectedIndexesChanged: func() {
fmt.Printf("SelectedIndexes: %v\n", tv.SelectedIndexes())
},
},
},
}.Run()
}