Hi All
Is there a way ( if so sample(s) ) to obtain user's "selected item(s)" from LISTBOX and/or GRID
PS: Without using OnDblClick event.
Regards
--
esgici
Obtaining Selection
Moderator: Rathinagiri
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Obtaining Selection
Viva INTERNATIONAL HMG
- Rathinagiri
- Posts: 5477
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Obtaining Selection
I think I don't get your point.
Now, we are getting the selected item(s) from the value property of the particular grid. Isn't it?
Now, we are getting the selected item(s) from the value property of the particular grid. Isn't it?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Obtaining Selection
Hi Rathirathinagiri wrote: Now, we are getting the selected item(s) from the value property of the particular grid. Isn't it?
Not quite.
When MULTISELECT is off (default) and VALUE is a single numeric, VALUE property alway updates properly by system while user changes current item into LISTBOX or GRID. In this case we can always obtain user's selection via VALUE property.
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
Regards
--
esgici
Viva INTERNATIONAL HMG
Re: Obtaining Selection
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
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- Roberto Lopez
- HMG Founder
- Posts: 4012
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Obtaining Selection
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
This is a very simple and clear sample.
Basically, a multiselect grid 'value' property returns a numeric array containing the positions of selected items.
To obtain the content of a row, you must use the 'item' property using the position as argument.
Remember that 'item' returns an array containing as much elements as columns have the grid.
If you want a specific cell content, you must use the 'cell' property.
ie:
win1.grid1.cell(nRow,nCol)
will give you the content of the cell located at nRow, nCol.
Regards,
Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Obtaining Selection
Thanks Grigory and Roberto
My fault was adding a VALUE <aValues> statement into LISTBOX/GRID definition
TIA
--
esgici
My fault was adding a VALUE <aValues> statement into LISTBOX/GRID definition
TIA
--
esgici
Viva INTERNATIONAL HMG