Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grid with fixed columns

Status
Not open for further replies.

vj

Programmer
Nov 18, 2000
58
MU
hi everyone,

i want to have a grid on my form ... hmm let's say with 20 columns and want the left most 2 columns and the last column to be fixed (that is ... column 1,2 and 20 will be fixed and will be visible at all times no mater which way the user scrolls). can i get some help on how to do that ?

thankx
Vijay
 
Hi Vijay,

You can fix the left-most columns or the right-most columns, but not both at the same time.

To fix the left-most columns, set the grid's Partition property to the number of pixels that you want to reserve for those columns, then set the PanelLink property to .F.

Note that this doesn't prevent the user from scrolling the left-most columns. It just means that they can scroll the right-most columns independently. I'm not sure if that's what you want. Try it and see.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
hi mike,

thankx for the info ... i tried it .. but .. that's not what i had in mind ... anyway .. i'll play more with it ...

thankx
 
Perhaps you could explain in a bit more detail what you had in mind. Did you mean that don't want to prevent the "fixed" columns from scrolling in either direction? I don't think that's possible. (You can remove the scrollbars, but the user will still be able to scroll with the cursor keys.)

Can you achieve your goal by creating two grids, side by side?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You can create three grids with the same recordsource.
The leftmost and the rightmost grid without scrollbars, recordmark and deletemark = .F.

Code:
PUBLIC ofrm
ofrm = CREATEOBJECT("Myform")
ofrm.show()

DEFINE CLASS MyForm as Form
	width = 500
	ADD OBJECT grdl as grid WITH recordsource = "cc",Scrollbars = 0,width = 50, RecordMark = .F.,DeleteMark = .F.,highlightstyle = 2,columncount =1
	ADD OBJECT grdmain as grid WITH recordsource = "cc",left = 50,highlightstyle = 2,columncount =2
	ADD OBJECT grdr as grid WITH recordsource = "cc",Scrollbars = 0,width = 50,left = 200, RecordMark = .F.,DeleteMark = .F.,highlightstyle = 2,columncount =1
	PROCEDURE Load
		CREATE CURSOR cc (iF1 I,cF2 C(20),cF3 C(20),nF4 N(10,2))
		INSERT INTO cc VALUES (1,'John','Doe',10.5)
		INSERT INTO cc VALUES (2,'Jim','Smith',7.3)
		INSERT INTO cc VALUES (3,'Jack','Ripper',8.7)
		INSERT INTO cc VALUES (11,'John','Doe',10.5)
		INSERT INTO cc VALUES (12,'Jim','Smith',7.3)
		INSERT INTO cc VALUES (13,'Jack','Ripper',8.7)
		INSERT INTO cc VALUES (21,'John','Doe',10.5)
		INSERT INTO cc VALUES (22,'Jim','Smith',7.3)
		INSERT INTO cc VALUES (23,'Jack','Ripper',8.7)
		INSERT INTO cc VALUES (31,'John','Doe',10.5)
		INSERT INTO cc VALUES (32,'Jim','Smith',7.3)
		INSERT INTO cc VALUES (33,'Jack','Ripper',8.7)
		GO TOP 
	ENDPROC
	
	PROCEDURE Init
		This.grdmain.column1.ControlSource = 'cc.cf2'
		This.grdmain.column2.ControlSource = 'cc.cf3'
		This.grdr.column1.ControlSource = 'cc.nf4'
		This.grdmain.left = This.grdl.left + This.grdl.width
		This.grdr.left = This.grdmain.left + This.grdmain.width
		BINDEVENT(This.grdl,"AfterRowColChange",This,"MyAfterRowColChange")
		BINDEVENT(This.grdmain,"AfterRowColChange",This,"MyAfterRowColChange")
		BINDEVENT(This.grdr,"AfterRowColChange",This,"MyAfterRowColChange")

		BINDEVENT(This.grdl.column1.text1,"KeyPress",This,"MyKeyPress")
		BINDEVENT(This.grdr.column1.text1,"KeyPress",This,"MyKeyPress")
		BINDEVENT(This.grdmain.column1.text1,"KeyPress",This,"MyKeyPress")
		BINDEVENT(This.grdmain.column2.text1,"KeyPress",This,"MyKeyPress")

		BINDEVENT(This.grdmain,"Scrolled",This,"MyScrolled")
	ENDPROC 
	PROCEDURE MyAfterRowColChange
		LPARAMETERS nColIndex
		LOCAL laEvent[1]
		AEVENTS(laEvent,0)
		DO CASE
		CASE laEvent[1] = This.grdl
			This.grdmain.Refresh
			This.grdr.Refresh
		CASE laEvent[1] = This.grdmain
			This.grdl.Refresh
			This.grdr.Refresh
		CASE laEvent[1] = This.grdr
			This.grdl.Refresh
			This.grdmain.Refresh
		ENDCASE
	ENDPROC
	PROCEDURE MyKeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl,llDo
		LOCAL laEvent[1]
		AEVENTS(laEvent,0)
		DO CASE
		CASE laEvent[1] = This.grdl.column1.text1 AND nKeyCode = 9 AND nShiftAltCtrl = 0
			This.grdmain.SetFocus
		CASE laEvent[1] = This.grdl.column1.text1 AND nKeyCode = 15 AND nShiftAltCtrl = 1 && shiflt + tab
			This.grdr.SetFocus
		CASE laEvent[1] = This.grdmain.columns[This.grdmain.columnCount].text1 AND nKeyCode = 9 AND nShiftAltCtrl = 0
			This.grdr.SetFocus
		CASE laEvent[1] = This.grdmain.column1.text1 AND nKeyCode = 15 AND nShiftAltCtrl = 1 && shiflt + tab
			This.grdl.SetFocus
		CASE laEvent[1] = This.grdr.column1.text1 AND nKeyCode = 9 AND nShiftAltCtrl = 0
			This.grdl.SetFocus
		CASE laEvent[1] = This.grdr.column1.text1 AND nKeyCode = 15 AND nShiftAltCtrl = 1 && shiflt + tab
			This.grdmain.SetFocus
		ENDCASE
	ENDPROC
	PROCEDURE MyScrolled
		LPARAMETERS nDirection
		This.grdl.Doscroll(m.nDirection)
		This.grdr.Doscroll(m.nDirection)
	ENDPROC
ENDDEFINE

Not perfect, but it's a start


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top