Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Highlighting a block in a grid
Message
From
31/12/1999 10:10:37
 
 
To
30/12/1999 19:56:06
Frank Mundo
WindowDressers, Inc.
Maine, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00310783
Message ID:
00310889
Views:
17
Hi Frank,

>Has anyone written the code that allows a user to highlight a block of "cells" in a grid? (similiar to highlighting a group of cells in Excel)

If you can figure out how to base DynamicBackColor on .ActiveRow (Do you know how to do this Ed?), then you can do it easily. Just trap for a Shift in the KeyPress and MouseUp commands, and save the 2 row and column coordinates. And then for a drag type select here is some nifty code (yas long as you can figure out how to base DynamicBackColor on .ActiveRow :-):
**************************************************
*-- Class Library:  d:\publicdomain\mhgridspreadsheet\mhgridspreadsheet.vcx
**************************************************


**************************************************
*-- Class:        mhgridspreadsheet (d:\publicdomain\mhgridspreadsheet\mhgridspreadsheet.vcx)
*-- ParentClass:  grid
*-- BaseClass:    grid
*
DEFINE CLASS mhgridspreadsheet AS grid


	Height = 200
	Width = 320
	nstartrow = 0
	nstartcol = 0
	nstoprow = 0
	nstopcol = 0
	Name = "mhgridspreadsheet"
	lhl = .F.


	PROCEDURE Init
		local loColumn
		for each loColumn in This.Columns
			loColumn.RemoveObject('Text1')
			loColumn.NewObject('Text1', ;
				'mhGridSSTextBox', 'mhGridSpreadSheet.vcx')
			loColumn.Text1.Visible = .t.
			loColumn.DynamicBackColor = "iif(This.lHL and " ;
				+ "Between(This.RelativeRow, This.nStartRow, This.nStopRow) and " ;
				+ "Between(" +  alltrim(str(loColumn.ColumnOrder)) ;
				+ ", This.nStartCol, This.nStopCol), rgb(0,0,255), rgb(255,255,255))"
		endfor
		This.Refresh()
	ENDPROC


	PROCEDURE AfterRowColChange
		LPARAMETERS nColIndex

		This.lHL = .F.
		This.Refresh()
	ENDPROC


ENDDEFINE
*
*-- EndDefine: mhgridspreadsheet
**************************************************


**************************************************
*-- Class:        mhgridsstextbox (d:\publicdomain\mhgridspreadsheet\mhgridspreadsheet.vcx)
*-- ParentClass:  textbox
*-- BaseClass:    textbox
*
DEFINE CLASS mhgridsstextbox AS textbox


	BorderStyle = 0
	Height = 23
	Margin = 0
	Width = 100
	Name = "mhgridsstextbox"


	PROCEDURE MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		local nWhere, nRelRow, nRelCol, nView, lnFirstRow, lnFirstCol

		with This.Parent.Parent

			store 0 to nWhere, nRelRow, nRelCol, nView
			if .GridHitTest(nXCoord, nYCoord, @nWhere, @nRelRow, @nRelCol, @nView);
				and nWhere = 3
				lnFirstCol = .nStartCol
				lnFirstRow = .nStartRow
				.nStartRow = min(lnFirstRow, nRelRow)
				.nStartCol = min(lnFirstCol, nRelCol)
				.nStopRow  = max(lnFirstRow, nRelRow)
				.nStopCol  = max(lnFirstCol, nRelCol)
				.lHL       = .T.
			else
				store 0 to .nStartRow, .nStartCol, ;
					.nStopRow, .nStopCol
				.lHL = .F.
			endif
			.Refresh()
		endwith
	ENDPROC


	PROCEDURE MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		debugout 'MouseDown'
		This.Parent.Parent.nStartRow = This.Parent.Parent.RelativeRow
		This.Parent.Parent.nStartCol = This.Parent.Parent.RelativeColumn
	ENDPROC


ENDDEFINE
*
*-- EndDefine: mhgridsstextbox
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform