Break On
$RC=setoption("NoVarsinstrings","on")
$RC=setoption("NoMacrosinstrings","on")
$COLUMNS = 8
$System = CreateObject("Kixtart.System")
$Form = $System.Form()
$Form.width = 100*$columns
$Form.Height = 400
$Form.Center()
$Listview = $Form.Controls.Add("ListView")
$Listview.Width = $Form.Width-100
$Listview.Height = 300
$Listview.Center()
$Listview.Top = 10
PopulateListview()
$EditButton = $Form.Controls.Add("ToolButton")
$EditButton.Text = "Edit"
$EditButton.Center()
$EditButton.Top = $ListView.Bottom + 15
$EditButton.OnClick = "EditListViewItem()"
$Form.Show()
$Form.SetFocus()
While $Form.Visible
$Nul = Execute($System.DoEvents)
Loop
Exit 0
Function EditListViewItem()
If $ListView.SelectedItems.Count < 1
Exit 0
Endif
$EditForm = $System.Form()
$EditForm.Width = 110*$ListView.Columns.Count
$EditForm.Height = 140
$EditForm.Center()
ReDim $aSelected[$ListView.Columns.Count - 1]
For Each $Item In $ListView.SelectedItems
For $x = 0 to $ListView.Columns.Count - 1
$aSelected[$x] = $Item.SubItems($x).Text
Next
Next
For $x=0 to UBound($aSelected)
$nul = Execute('$Box'+$x+' = $EditForm.Controls.Add("TextBox")')
$nul = Execute('$Box'+$x+'.Text = $aSelected[$x]')
If $x=0
$nul = Execute('$Box'+$x+'.Left = 5')
Else
$nul = Execute('$Box'+$x+'.Left = $Box'+($x-1)+'.Right+5')
Endif
$nul = Execute('$Box'+$x+'.top = 20')
Next
$EditSaveButton = $EditForm.Controls.Add("ToolButton")
$EditSaveButton.Text = "Save"
$EditSaveButton.OnClick = "SaveListViewItem()"
$EditSaveButton.Width = 80
$EditSaveButton.Center()
$EditSaveButton.Top = $Box0.Bottom+15
$Form.Hide()
$EditForm.Show()
$EditForm.SetFocus()
While $EditForm.Visible
$Nul = Execute($EditForm.DoEvents)
Loop
$Form.Show()
Exit 0
EndFunction
Function SaveListViewItem()
For Each $Item In $ListView.SelectedItems
For $x = 0 to $ListView.Columns.Count
$nul = Execute('$info = $Box'+$x+'.Text')
$Item.SubItems($x).Text = $info
Next
Next
$EditForm.Hide()
EndFunction
Function PopulateListView()
For $x=1 to $columns
$nul = Execute('$Col'+$x+' = $Listview.Columns.Add("Col "+$x,$ListView.Width/$columns-1,2)')
Next
For $x=0 to 10
$row = $ListView.Items.Insert($x)
For $y=0 to $ListView.Columns.Count-1
$row.SubItems($y).Text = "Test "+$x
Next
Next
$ListView.SelectedItems = ""
EndFunction