[Gambas-user] Gridview multiple select... how to read each selected row?

Stephen Bungay sbungay at ...981...
Mon Apr 14 23:28:35 CEST 2008


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.

Lee McPherson wrote:
> I'm getting a little confused as to how to read the data from multiple 
> selections from a gridview.  For example, if I have four rows 
> highlighted (selected by dragging the mouse over them), I want to be 
> able to push a button and read the first column from each of those four 
> rows and stick them into a database.  I was thinking I'd have to use a 
> FOR EACH statement, but I am not sure how to do this with a gridview.
> 
> Can anyone bang out a quick example to try? 
> 
> Thanks,
> Lee
> 
> -------------------------------------------------------------------------
> 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