[Gambas-user] search in gridview or columnview

Stefano Palmeri rospolosco at ...152...
Wed Jun 4 16:25:33 CEST 2008


Il Wednesday 04 June 2008 15:36:38 Peter Mathijssen ha scritto:
> It seems that this code:
>
>  DIM iCountCol, iCountRow AS Integer
>
>   IF Len(txtsearch.text) = 0 THEN
>     FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
>       GridView1.Rows[iCountRow].Selected = FALSE
>     NEXT
>     RETURN
>   END IF
>
>   GridView1.Mode = Select.Multiple
>
>   FOR iCountRow = 0 TO (GridView1.Rows.Count - 1)
>     FOR iCountCol = 0 TO (GridView1.Columns.Count - 1)
>         IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
> gb.Case) > 0 THEN
>         GridView1.Rows[iCountRow].Selected = TRUE
>         ELSE
>         GridView1.Rows[iCountRow].Selected = FALSE
>       ENDIF
>     NEXT
>   NEXT
>
> only finds strings in column 1 and not in column 0.
> It is a gridview with two columns, both columns contain strings of text.
>
> Strange, the code looks fine. I just adapted it a bit from Stefano.
>
> Peter
> -------------------------------------------------------------------------

Hi, Peter.

It seems you forget a BREAK. In the way you wrote
the code, the same Row could be selected and
unselected in the same loop.
To fix it add a BREAK when the Row is selected: 

IF InStr(GridView1[iCountRow, iCountCol].Text, txtsearch.Text, 0,
 gb.Case) > 0 THEN
     GridView1.Rows[iCountRow].Selected = TRUE
     BREAK

Example attached.

Bye,

Stefano


> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gridview2-0.0.1.tar.gz
Type: application/x-tgz
Size: 7895 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20080604/1bb37517/attachment.bin>


More information about the User mailing list