Is there a way ( if so sample(s) ) to obtain user's "selected item(s)" from LISTBOX and/or GRID
![Question :?:](./images/smilies/icon_question.gif)
PS: Without using OnDblClick event.
Regards
--
esgici
Moderator: Rathinagiri
Hi Rathirathinagiri wrote: Now, we are getting the selected item(s) from the value property of the particular grid. Isn't it?
Esgici,esgici wrote:...
When MULTISELECT is on, VALUE property must be a numeric array. In this case user can select single or multiple items into control ( LISTBOX / GRID ) by using almost every selection keystrokes ( up/down keys with shift/ctrl combinations ) and mouse movements (with again shift/ctrl combinations ) except Ctrl-A.
Unfortunately in this second case VALUE array does not update internally by system and we cannot obtain user selection(s).
At least I can't succeed![]()
Code: Select all
/*
* Harbour MiniGUI Hello World Demo
* (c) 2002-2004 Roberto Lopez <harbourminigui@gmail.com>
*/
#include "minigui.ch"
Function Main
DEFINE WINDOW Win1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'Hello World!' ;
MAIN
DEFINE LISTBOX LIST1
ROW 10
COL 10
WIDTH 100
HEIGHT 110
ITEMS { '01','02','03','04','05','06','07','08','09','10' }
MULTISELECT .T.
END LISTBOX
DEFINE BUTTON BUTTON1
ROW 10
COL 150
CAPTION 'Get Selected Items'
ACTION SelectTest()
WIDTH 150
END BUTTON
END WINDOW
ACTIVATE WINDOW Win1
Return Nil
Procedure SelectTest
local x, n_for, n_pos
local a_result := win1.list1.value
if len( a_result ) == 0
return
end
x := ''
for n_for=1 to len( a_result )
n_pos := a_result[ n_for ]
x += str(n_for) + ": "+ win1.list1.item( n_pos ) + chr(13)
next
msginfo( x , 'Selected item(s): ' + alltrim( str( len( a_result ) ) ) )
Return
Esgici,gfilatov wrote:Esgici,esgici wrote:...
When MULTISELECT is on, VALUE property must be a numeric array. In this case user can select single or multiple items into control ( LISTBOX / GRID ) by using almost every selection keystrokes ( up/down keys with shift/ctrl combinations ) and mouse movements (with again shift/ctrl combinations ) except Ctrl-A.
Unfortunately in this second case VALUE array does not update internally by system and we cannot obtain user selection(s).
At least I can't succeed![]()
Kindly try the following working sample:
Code: Select all
/* * Harbour MiniGUI Hello World Demo * (c) 2002-2004 Roberto Lopez <harbourminigui@gmail.com> */ #include "minigui.ch" Function Main DEFINE WINDOW Win1 ; AT 0,0 ; WIDTH 400 ; HEIGHT 400 ; TITLE 'Hello World!' ; MAIN DEFINE LISTBOX LIST1 ROW 10 COL 10 WIDTH 100 HEIGHT 110 ITEMS { '01','02','03','04','05','06','07','08','09','10' } MULTISELECT .T. END LISTBOX DEFINE BUTTON BUTTON1 ROW 10 COL 150 CAPTION 'Get Selected Items' ACTION SelectTest() WIDTH 150 END BUTTON END WINDOW ACTIVATE WINDOW Win1 Return Nil Procedure SelectTest local x, n_for, n_pos local a_result := win1.list1.value if len( a_result ) == 0 return end x := '' for n_for=1 to len( a_result ) n_pos := a_result[ n_for ] x += str(n_for) + ": "+ win1.list1.item( n_pos ) + chr(13) next msginfo( x , 'Selected item(s): ' + alltrim( str( len( a_result ) ) ) ) Return