I have set up a Listview and a button where the user can highlight an item in the list view and then click the button to jump to a procedure based upon the item selected and it works ok.
I can set it up without the button and have the user double click an item in the Listview and have it jump to a procedure based upon the item double clicked and that works ok.
My problem is that I want to give the user the option of clicking on a button or double clicking an item but I can’t seem to accomplish this. Can anyone show me a the best way to achieve this on Window OS?
Thanks
Listview problem
Listview problem
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
- StarBootics
- Addict
- Posts: 1006
- Joined: Sun Jul 07, 2013 11:35 am
- Location: Canada
Re: Listview problem
This code should do the tricks :
Best regards
StarBootics
Code: Select all
Procedure ProcedureToRun()
Debug GetGadgetText(0)
EndProcedure
If OpenWindow(0,0,0,400,300,"ListViewGadget",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0,5,5,250,120)
For a=1 To 12
AddGadgetItem (0,-1,"Elément "+Str(a)+" de la boîte à liste") ; défini le contenu de la boîte de liste
Next
SetGadgetState(0,9) ; sélectionne le dixième élément (la numérotation commmence à 0)
ButtonGadget(1, 5, 130, 250, 34, "The Button")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftDoubleClick
ProcedureToRun()
EndIf
Case 1
ProcedureToRun()
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case 0
Break
Default
CloseWindow(EventWindow())
EndSelect
EndSelect
ForEver
End
EndIf
StarBootics
The Stone Age did not end due to a shortage of stones !
Re: Listview problem
Merci pour le partage
Re: Listview problem
Merci beaucoup. Très apprécié.
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
Re: Listview problem
Or, if you are a friend of binding events:
Code: Select all
Enumeration
#Window
#Listview
#Button
EndEnumeration
Procedure ProcedureToRun(Originator.s)
Debug GetGadgetText(#Listview) + " " + Originator
EndProcedure
Procedure ButtonClick()
ProcedureToRun("Button")
EndProcedure
Procedure ListviewClick()
ProcedureToRun("Listview")
EndProcedure
Procedure WindowClose()
CloseWindow(EventWindow())
EndProcedure
If OpenWindow(#Window, 0, 0, 400, 300, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(#Listview, 5, 5, 250, 120)
For a = 1 To 12
AddGadgetItem (#Listview, -1, "Elément "+Str(a)+" de la boîte à liste") ; défini le contenu de la boîte de liste
Next
SetGadgetState(#Listview, 9) ; sélectionne le dixième élément (la numérotation commmence à 0)
ButtonGadget(#Button, 5, 130, 250, 34, "The Button")
;
BindGadgetEvent(#Button, @ButtonClick())
BindGadgetEvent(#Listview, @ListviewClick(), #PB_EventType_LeftDoubleClick)
BindEvent(#PB_Event_CloseWindow, @WindowClose(), #Window)
Repeat
Select WaitWindowEvent()
EndSelect
ForEver
EndIf
PB 5.73 on Windows 10 & OS X High Sierra