[Gambas-user] Gridview multiple select... how to read each selected row?
Stephen Bungay
sbungay at ...981...
Tue Apr 15 16:06:33 CEST 2008
Replying to my own emails... worse than talking to yourself...
I forgot to thank Benoit for the info.
Many thanks to Benoit for pointing out that 'rows' does indeed have a
'selected' property. Dunno how I missed finding it, but I did.
Stephen Bungay wrote:
> New info. There IS a way to check the state of the row, I didn't see
> it and it is not (yet) documented but hopefully it soon will be.
>
> Gridview1.rows[X].selected
>
> There... that's MUCH better and no more fussing about with the
> collection. Something like the example below should work rather nicely...
>
> For X = 1 to GridView1.rows.count
> if GridView1.rows[X].selected then
> ' insert processing logic here
> end if
> Next
>
>
> Steve.
>
>
> Lee McPherson wrote:
>> Thanks Stephen and Benoit,
>>
>> I understand Stephen's suggestion, but it seems to only work with using the
>> CTRL key clicking each row with a mouse. Now if you were to do the same
>> capture (under gridview_select event) by VERY quickly dragging the mouse
>> over several rows at time, I can actually get it to skip capturing some of
>> the rows! My project will be using an LCD touch screen, so the user will
>> only be able to "drag select" and not point and click each row, so his
>> suggestion might not work for me. I say "might" because I might be doing
>> something wrong. Here is some code to replicate what I did. (with an
>> gridview object called Gridview1, and a button to print the collection
>> called Button1) I ended up using the MouseDown event on gridview1 to clear
>> the collection since I'm only worried about mouse drags to select multiple
>> events.
>>
>> PUBLIC rowsel AS COLLECTION
>>
>> PUBLIC SUB gridview1_Select()
>> DIM rownumber AS String
>> IF gridsel.Exist(gridView1.row)
>> gridsel.Remove(gridView1.row)
>> ELSE
>> gridsel.Add(gridView1.row, gridView1.row)
>> ENDIF
>> END
>>
>> PUBLIC SUB gridView1_MouseDown()
>> gridsel.Clear
>> END
>>
>> PUBLIC SUB Button9_Click()
>> DIM rownumber AS String
>> FOR EACH rownumber IN gridsel
>> PRINT "R: " & rownumber
>> NEXT
>> END
>>
>>
>> On Mon, Apr 14, 2008 at 8:13 PM, Benoit Minisini <
>> gambas at ...1...> wrote:
>>
>>> On lundi 14 avril 2008, Stephen Bungay wrote:
>>>> Hi Lee;
>>>> I never did understand why the grid control would allow you to
>>>> select multiple items and not have a mechanism to indicate which rows
>>>> were selected and which were not. Perhaps it does have such a mechanism
>>>> but I haven't been able to find it. Of course it could be deeply buried
>>>> but then thats a bad thing too.
>>>> Anyway, what you can probably do is create a collection that holds
>>>> each selected item's row number, use the row number as the index into
>>>> the collection. Each time the select event is raised by the control,
>>>> trap it and store the row that was clicked on in the collection. If you
>>>> get an error when trying to add the row number to the collection because
>>>> the index key already exists then you know the row was already stored
>>>> and the user has clicked on a row to deselected it. Remove that row from
>>>> the collection, thus keeping the information in the collection in sync
>>>> with the selected rows in the grid.
>>>> IMHO this is a kludge to accommodate the grid control which should
>>>> have a mechanism that exposes the selected state of it's row items to
>>>> the programmer.
>>>>
>>>> Steve.
>>>>
>>> At the moment, you have to test the Selected property of each row to get
>>> the
>>> selection.
>>>
>>> I admit that the process is not optimal! Maybe I should add a Selection
>>> property that would return the indexes of all selected rows?
>>>
>>> --
>>> Benoit Minisini
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>>> Don't miss this year's exciting event. There's still time to save $100.
>>> Use priority code J8TL2D2.
>>>
>>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>> Don't miss this year's exciting event. There's still time to save $100.
>> Use priority code J8TL2D2.
>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list