[Gambas-user] Gridview select and deselect

Stefano Palmeri rospolosco at ...152...
Fri Apr 17 17:03:50 CEST 2009


Il venerdì 17 aprile 2009 16:08:45 charlesg ha scritto:
> Hi all
>
> Having selected a gridview row with a click, I cannot deselect it with
> another click as should be normal.
>
> After reading an old thread here, I have fudged it with an array bSelected
> which keeps track of which rows in gvRequired are selected.
>
> '-------------------------------------------------------------
> PUBLIC SUB gvRequired_Click()
>   IF bSelected[gvRequired.Row] THEN
>     bSelected[gvRequired.row] = FALSE
>   ELSE
>     bSelected[gvRequired.row] = TRUE
>   ENDIF
>   txtItem.SetFocus
> END
> '-------------------------------------------------------------
> PUBLIC SUB gvRequired_LostFocus()
>     DIM x AS Integer
>
>     gvRequired.Rows.Unselect
>     FOR x = 0 TO gvRequired.Rows.count - 2
>         IF bSelected[x] THEN
>             gvRequired.Rows[x].Selected = TRUE
>         ENDIF
>     NEXT
> END
> '-------------------------------------------------------------
>
> This can't interpret shift+click and ctrl+click used to create the
> selection. How can I trap shift+click on a gridview?
>
> Or am I as usual making a whale of a gambas :)
>
> rgds

You could use the MouseDown event. Example:


PUBLIC SUB GridView1_MouseDown()

  IF Mouse.Shift THEN 
    PRINT "You clicked while pressing the Shift key"
  ENDIF   

END

Saluti,

Stefano




More information about the User mailing list