#128715 - 2004-10-31 05:33 PM
ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
Need an example how to Add items from a listview to another, by double clicking.
Assume that ListView1 is populated with several items, and listview2 is empty. By double clicking on an items presented in listview1, the item should be placed in/moved to listview2, And vice versa.
Anybody with good ideas?
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#128717 - 2004-10-31 06:16 PM
Re: ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
Where do u find this ListViewSelectedItemCollection ...
Its not much regading ListViewSelectedItemCollection at Kixforms BBS or Doc...
hmmmm...not much for help....
Edited by JazzM (2004-10-31 06:18 PM)
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#128718 - 2004-10-31 06:30 PM
Re: ListView.OnDoubleClick
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Here's a quickie example:
Code:
Break on
$System = CreateObject("Kixtart.System")
$Form = $System.Form() $Form.Size = 640,480 $Form.Text = "Bigglesworth-Ware"
$ToolBar = $Form.GroupBox() $ToolBar.Height = 30 $ToolBar.Dock = "Top" $ToolBar.DockPadding = 2
$ListView1 = $Form.ListView() $ListView1.Dock = "Left" $ListView1.Right = $Form.ClientWidth / 2 $ListView1.SmallImageList = $System.BuiltinImageList $ListView1.HideSelection = 0 $ListView1.OnDoubleClick = "ListView1DoubleClick()"
$Col = $ListView1.Columns.Add("Installed Software",-2)
For $i = 0 to 10 $Item = $ListView1.Items.Add("Package#$i",$i) Next
For Each $Item In $ListView1.SelectedItems $Item.Selected = 0 Next
$ListView1.Columns(0).Width = -1 $ListView1.Columns(0).Width = -2 $ListView1.Sorted = 1
$Splitter = $Form.Splitter()
$ListView2 = $Form.ListView() $ListView2.Dock = "Fill" $ListView2.SmallImageList = $System.BuiltinImageList $ListView2.HideSelection = 0 $ListView2.OnDoubleClick = "ListView2DoubleClick()"
$= $ListView2.Columns.Add("Available Software",-2)
For $i = $i to 20 $Item = $ListView2.Items.Add("Package#$i",$i) Next
For Each $Item In $ListView2.SelectedItems $Item.Selected = 0 Next
$ListView2.Columns(0).Width = -1 $ListView2.Columns(0).Width = -2 $ListView2.Sorted = 1
$Form.Center() $Form.Show() While $Form.Visible $=Execute($Form.DoEvents()) Loop
Exit 1
Function ListView1DoubleClick()
dim $item
$item = $ListView2.Items.Add($ListView1.FocusedItem.Text,$ListView1.FocusedItem.ImageIndex) $ListView1.FocusedItem.Remove()
EndFunction
Function ListView2DoubleClick()
dim $item
$item = $ListView1.Items.Add($ListView2.FocusedItem.Text,$ListView2.FocusedItem.ImageIndex) $ListView2.FocusedItem.Remove()
EndFunction
|
Top
|
|
|
|
#128720 - 2004-11-01 11:33 AM
Re: ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
Shawn, If the listviews has several Sub-items, how should i define the function to get everything moved on doubleclick?
e.g. $ListView1.Items.Add $Item.Subitems(0).Text $Item.Subitems(1).Text $Item.Subitems(2).Text $Item.Subitems(3).Text
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#128721 - 2004-11-01 02:12 PM
Re: ListView.OnDoubleClick
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Your right, should be able to use SubItems(n) to move all the stuff back and forth, for example:
Code:
Break on
$System = CreateObject("Kixtart.System")
$Form = $System.Form() $Form.Size = 640,480 $Form.Text = "Bigglesworth-Ware"
$ToolBar = $Form.GroupBox() $ToolBar.Height = 30 $ToolBar.Dock = "Top" $ToolBar.DockPadding = 2
$ListView1 = $Form.ListView() $ListView1.Dock = "Left" $ListView1.Right = $Form.ClientWidth / 2 $ListView1.OnDoubleClick = "ListView1DoubleClick()"
$= $ListView1.Columns.Add("A") $= $ListView1.Columns.Add("B") $= $ListView1.Columns.Add("C")
For $i = 0 to 30 Step 3 $Item = $ListView1.Items.Add($i) $Item.SubItems(1).Text = $i+1 $Item.SubItems(2).Text = $i+2 Next
$Splitter = $Form.Splitter()
$ListView2 = $Form.ListView() $ListView2.Dock = "Fill" $ListView2.OnDoubleClick = "ListView2DoubleClick()"
$= $ListView2.Columns.Add("A") $= $ListView2.Columns.Add("B") $= $ListView2.Columns.Add("C")
$Form.Center() $Form.Show() While $Form.Visible $=Execute($Form.DoEvents()) Loop
Exit 1
Function ListView1DoubleClick()
dim $item
$item = $ListView2.Items.Add($ListView1.FocusedItem.Text,$ListView1.FocusedItem.ImageIndex)
$item.SubItems(1).Text = $ListView1.FocusedItem.SubItems(1).Text $item.SubItems(2).Text = $ListView1.FocusedItem.SubItems(2).Text
$ListView1.FocusedItem.Remove()
EndFunction
Function ListView2DoubleClick()
dim $item
$item = $ListView1.Items.Add($ListView2.FocusedItem.Text,$ListView2.FocusedItem.ImageIndex)
$item.SubItems(1).Text = $ListView2.FocusedItem.SubItems(1).Text $item.SubItems(2).Text = $ListView2.FocusedItem.SubItems(2).Text
$ListView2.FocusedItem.Remove()
EndFunction
|
Top
|
|
|
|
#128722 - 2004-11-20 03:35 PM
Re: ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
Thanx Shawn,
Just a quick Q:
How do I add an "specific" smallimage/icon on items in listview?
e.g. Icon=34 or Image=C:\Icons\Myicon.ico
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#128724 - 2004-11-20 05:49 PM
Re: ListView.OnDoubleClick
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Jens is spot on ...
1) Plug the builtin (kixforms) imagelist into both ListViews like this:
Code:
$ListView1.SmallImageList = $System.BuiltinImageList
$ListView2.SmallImageList = $System.BuiltinImageList
if you need custom icons in the list, then you have to "Add" them.
2) Specify the ImageIndex of the each item, like this (we're just using a random image index for this example):
Code:
$Item.ImageIndex = rnd(50)
And thats all there is ... please note - you can only specify an icon for the first item in a row ... subitems can't have icons. Heres the full example:
Code:
Break on
$System = CreateObject("Kixtart.System")
$Form = $System.Form()
$Form.Size = 640,480
$Form.Text = "Bigglesworth-Ware"
$ToolBar = $Form.GroupBox()
$ToolBar.Height = 30
$ToolBar.Dock = "Top"
$ToolBar.DockPadding = 2
$ListView1 = $Form.ListView()
$ListView1.Dock = "Left"
$ListView1.Right = $Form.ClientWidth / 2
$ListView1.OnDoubleClick = "ListView1DoubleClick()"
$ListView1.SmallImageList = $System.BuiltinImageList
$= $ListView1.Columns.Add("A")
$= $ListView1.Columns.Add("B")
$= $ListView1.Columns.Add("C")
For $i = 0 to 30 Step 3
$Item = $ListView1.Items.Add($i)
$Item.ImageIndex = rnd(50)
$Item.SubItems(1).Text = $i+1
$Item.SubItems(2).Text = $i+2
Next
$Splitter = $Form.Splitter()
$ListView2 = $Form.ListView()
$ListView2.Dock = "Fill"
$ListView2.OnDoubleClick = "ListView2DoubleClick()"
$ListView2.SmallImageList = $System.BuiltinImageList
$= $ListView2.Columns.Add("A")
$= $ListView2.Columns.Add("B")
$= $ListView2.Columns.Add("C")
$Form.Center()
$Form.Show()
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1
Function ListView1DoubleClick()
dim $item
$item = $ListView2.Items.Add($ListView1.FocusedItem.Text,$ListView1.FocusedItem.ImageIndex)
$item.SubItems(1).Text = $ListView1.FocusedItem.SubItems(1).Text
$item.SubItems(2).Text = $ListView1.FocusedItem.SubItems(2).Text
$ListView1.FocusedItem.Remove()
EndFunction
Function ListView2DoubleClick()
dim $item
$item = $ListView1.Items.Add($ListView2.FocusedItem.Text,$ListView2.FocusedItem.ImageIndex)
$item.SubItems(1).Text = $ListView2.FocusedItem.SubItems(1).Text
$item.SubItems(2).Text = $ListView2.FocusedItem.SubItems(2).Text
$ListView2.FocusedItem.Remove()
EndFunction
-Shawn
|
Top
|
|
|
|
#128726 - 2004-11-21 05:09 PM
Re: ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
I cannot get it work on my code:
$lsvList1 = $Form.ListView
$lsvList1.Height = 425 $lsvList1.Left = 12 $lsvList1.Top = 15 $lsvList1.Width = 200 $lsvList1.MultiSelect = 0 $lsvList1.Dock = "Left" $lsvList1.OnDoubleClick = "lsvList1DC()"
$lsvListQ = $Form.ListView $lsvListQ.Height = 110 $lsvListQ.Left = 590 $lsvListQ.Top = 15 $lsvListQ.Width = 270 $lsvListQ.MultiSelect = 1
$ = $lsvList1.Columns.Add("Name",180) $ = $lsvList1.Columns.Add("Version",80) $ = $lsvList1.Columns.Add("Path",0) $ = $lsvList1.Columns.Add("ID",0)
$SWProd = "\\Server1\Share\Software1\Prroduct1.ini"
$Item0 = $lsvList1.Items.Add("")
$key = ReadProfileString($SWProd,"","")
For Each $Keys In Split($key,Chr(10)) If $Keys $Item = $lsvList1.Items.Add() $Item.Text = "Item" $Name = ReadProfileString($SWProd,$Keys,"SWName")+@CRLF $Item.Subitems(0).Text = $Name $Ver = ReadProfileString($SWProd $Keys,"SWVersion")+@CRLF $Item.Subitems(1).Text = $Ver $Path = ReadProfileString($SWProd,$Keys,"SWPath")+@CRLF $Item.Subitems(2).Text = $Path $Item.Subitems(3).Text = $Keys $NmVr = $Name + $Ver
$lsvList1.Columns.Sorted = "True" $lsvList1.item.Sorted = "True"
$lsvList1.HideSelection = "true" EndIf
Function lsvList1DC() Dim $item $item = $lsvListQ.Items.Add($lsvList1.FocusedItem.Text,$lsvList1.FocusedItem.ImageIndex)
;here i want a specifict icon for each item which addes to this listview! ;e.g. Icon=34 or Image=C:\Icons\Myicon.ico, not any random ico or image
$item.SubItems(1).Text = $lsvList1.FocusedItem.SubItems(1).Text $item.SubItems(2).Text = $lsvList1.FocusedItem.SubItems(2).Text $item.SubItems(3).Text = $lsvList1.FocusedItem.SubItems(3).Text
EndIf EndFunction
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#128728 - 2004-11-21 09:16 PM
Re: ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
Ahh... why the endif is there½!"# just ignore it...
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#128730 - 2004-11-22 02:25 PM
Re: ListView.OnDoubleClick
|
JazzM
Getting the hang of it
Registered: 2004-04-23
Posts: 91
|
Now its gone. damn endif is gone/removed. ignore=delete
Function lsvList1DC()
Dim $item
$item = $lsvListQ.Items.Add($lsvList1.FocusedItem.Text,$lsvList1.FocusedItem.ImageIndex)
;here i want a specifict icon for each item which addes to this listview! ;e.g. Icon=34 or Image=C:\Icons\Myicon.ico, not any random ico or image
$item.SubItems(1).Text = $lsvList1.FocusedItem.SubItems(1).Text $item.SubItems(2).Text = $lsvList1.FocusedItem.SubItems(2).Text $item.SubItems(3).Text = $lsvList1.FocusedItem.SubItems(3).Text
EndFunction
_________________________
I will always look out from behind these eyes...
|
Top
|
|
|
|
#213586 - 2018-09-14 06:11 PM
Re: ListView.OnDoubleClick
[Re: Shawn]
|
tito
Fresh Scripter
Registered: 2002-04-03
Posts: 11
Loc: seattle washington
|
@Shawn -- Thank you. I've been racking my brain for the correct code syntax to select an item/subitem and pass it to a variable. I'd prefer to just select one subitem. but this gets me further than I got. I created a listview container. added columns. The ListView items are populated with specific attributes from the results of an AD Query. (using fnLDAPQuery() as the AD Search tool. Author: Christopher Shilt and Contributor Jens Meyer.)
Thanks Shawn and the others that continue to support/contribute to this kix and KixForms forum
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|