Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid multiselect
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00128997
Message ID:
00129016
Vues:
28
>I am trying to get the same behavior in a grid that is available in a list box. I want to multiselect several records in a grid to mark a checkbox control I've placed in one of the grids columns. The Idea here is to allow the user to multiselect several records of the grid and either deselect the checkbox or select the checkbox instead of having to click on the checkbox for each record. I would also like to allow the users to left click mouse and drag down the rows of the grid and have them selected that way as well, just like you can in the list box control. Does anyone have any suggestions on how to implement this technique for a grid?
>
>Thanks for any ideas!
>
>John.

Hi John,
This code will allow you to select or deselect rows in your grid and I added some extra snip to reorder the data by clicking on the header. Then when you take action on your selections you can scan the array again for the keys. Hope I didn't leave anything out! ;)

**** Add this to mygrid Init() where alias.idx is the record source key
**** You can change the color as you like.
**** You must add an array property to the form ie. thisform.pkarray
dodefault()
this.Highlight = .f.
this.GridLines = 0
this.SetAll("DynamicBackColor",; "IIF(ascan(thisform.pkarray,alias.idx)>0,rgb(0,0,128),rgb(255,255,255))",;
"COLUMN")
this.SetAll("DynamicForeColor", ;
"IIF(ascan(thisform.pkarray,alias.idx)>0,rgb(255,255,255),rgb(0,0,0))",;
"COLUMN")


****Add this to mygrid.columnx.text1.click()
LOCAL lnArraySize, lnArrayRow

lnArraySize = alen(thisform.pkarray, 1)
dimension thisform.pkarray[lnArraySize+1]
ains(thisform.pkarray, 1)
thisform.pkarray(1) = alias.idx
this.GotFocus()
thisform.refresh()


**** Add this to mygrid.columnx.text1.rightclick()
LOCAL lnArraySize, lnArrayRow

lnArraySize = alen(thisform.pkarray, 1)
for x = 1 to lnArraySize-1
if like(allt(str(alias.idx)), allt(str(thisform.pkarray[x])))
thisform.pkarray[x] = 0
endif
endfor
this.GotFocus()
thisform.refresh()



**** Add this to mygrid.columnx.header1.click()
**** The field bound to the textbox in the column must be indexed
LOCAL cSource, nDotPos, nStrlen, nRecord

nRecord = recno()
nDotPos = rat(".", allt(this.parent.Text1.ControlSource))
nStrLen = len(allt(this.parent.Text1.ControlSource))
cSource = right(allt(this.parent.Text1.ControlSource),nStrLen-nDotPos)

set order to tag &cSource
thisform.lockscreen = .T.
thisform.refresh()
go nRecord
thisform.lockscreen = .F.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform