Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grids - Multi-select - Is it possible?
Message
From
06/03/2008 03:34:55
 
 
To
05/03/2008 08:42:40
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01298851
Message ID:
01299232
Views:
11
>Hi All,
>
>With a grid in vfp8, is it possible to get it to do multi-selection of the records?
>
>Can you point me to some examples?
>
>I have a single table, that I need to allow the user to view and delete or undelete as needed. No other editing of record is allowed. But they want to be able to highlight several rows and hit a button to mark records as deleted.
>
>TIA
>Beth

A simple start point
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show

DEFINE CLASS form1 AS form


	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT grid AS grid WITH ;
		Height = 200, ;
		Left = 12, ;
		Top = 17, ;
		Width = 320, ;
		AllowCellSelection = .F., ;
		Name = "Grid"


	PROCEDURE Load
		CREATE CURSOR test (f1 I AUTOINC ,F2 C(30) DEFAULT "RECORD"+STR(RECCOUNT()))
		FOR K=1 TO 100
			APPEND BLANK
		NEXT
	ENDPROC


	PROCEDURE grid.Init
		THIS.AddProperty("Selected[1]")
		DIMENSION this.Selected[RECCOUNT(m.this.RecordSource)]
		this.SetAll("DynamicBackColor","IIF(this.Selected[RECNO()],0x80FF,0xFFFFFF)")
		LOCATE
	ENDPROC


	PROCEDURE grid.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.AddProperty("KeyShift",m.nShift)
	ENDPROC


	PROCEDURE grid.Click
		IF m.this.KeyShift = 2
			this.Selected[RECNO()]=not this.Selected[RECNO()]
			IF this.Selected[RECNO()]
				this.HighlightBackColor = 0x80FF
			ELSE
				grid::ResetToDefault("HighlightBackColor")
			ENDIF
		ENDIF
	ENDPROC


	PROCEDURE grid.AfterRowColChange
		LPARAMETERS nColIndex
		grid::ResetToDefault("HighlightBackColor")
	ENDPROC


ENDDEFINE
Previous
Reply
Map
View

Click here to load this message in the networking platform