Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Programmatically set column widths in dynamic grid?
Message
From
13/08/2002 15:53:27
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
How To Programmatically set column widths in dynamic grid?
Miscellaneous
Thread ID:
00689312
Message ID:
00689312
Views:
82
I have a form that has grid on it that is hidden until the user selects a table to view. The grid needs to be dynamic. When the user clicks on the command button to open a table, it creates a cursor from the selected table that is viewed in the grid. Everything works fine except that I want to be able to determine if the columns in the grid are not as wide as column's captions to adjust the column width at least to that width if not wider. Any ideas? I know I need to step through the properties of the grid and check the current column width against the len of the caption, but how to do that? In general, how to create a better looking dynamic grid?

TIA,
Tracy
*-Browse open tables
PUBLIC loform
loform=CREATEOBJECT("browsetables")
loform.show()
RETURN


DEFINE CLASS browsetables AS form


	DataSession = 2
	Top = 0
	Left = 0
	Height = 424
	Width = 600
	DoCreate = .T.
	Caption = "Browse Tables - Please Select a Table to Browse"
	ControlBox = .F.
	Name = "Form1"
	lctable = .F.


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 12, ;
		Left = 423, ;
		Height = 36, ;
		Width = 84, ;
		Picture = "..\..\program files\microsoft visual foxpro 7\wizards\graphics\open.bmp", ;
		Caption = "Open Table", ;
		TabStop = .F., ;
		Name = "Command1"


	ADD OBJECT grd_view AS grid WITH ;
		Height = 324, ;
		Left = 12, ;
		ReadOnly = .T., ;
		RecordSource = "", ;
		RecordSourceType = 1, ;
		TabStop = .F., ;
		Top = 84, ;
		Visible = .F., ;
		Width = 576, ;
		Name = "grd_view"


	ADD OBJECT lblfilename AS label WITH ;
		Caption = "", ;
		Height = 24, ;
		Left = 13, ;
		Top = 51, ;
		Width = 348, ;
		Name = "lblfilename"


	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 12, ;
		Left = 507, ;
		Height = 36, ;
		Width = 84, ;
		Picture = "..\..\program files\microsoft visual foxpro 7\samples\tastrade\bitmaps\close.bmp", ;
		Caption = "Exit", ;
		TabStop = .F., ;
		Name = "Command2"


	PROCEDURE Release
		CLOSE TABLES
		DODEFAULT()
	ENDPROC


	PROCEDURE command1.Click
		THISFORM.lctable=GETFILE("dbf")
		IF !EMPTY(thisform.lctable)
			IF USED('gridview')
				USE IN gridview
			ENDIF
			CLOSE TABLES
			USE (thisform.lctable) ALIAS mytable
			thisform.grd_view.recordsource = ""
			*-- run query
			SELECT * FROM mytable into cursor gridview
			thisform.grd_view.recordsource ="gridview"
			thisform.grd_view.visible=.t.
			thisform.grd_view.refresh()
			USE IN mytable
			THISFORM.lblfilename.caption=thisform.lctable
		ELSE
			THISFORM.grd_view.recordsource=""
			thisform.grd_view.visible=.f.
			THISFORM.lblfilename.caption="NO table selected"
		ENDIF
		RETURN
	ENDPROC


	PROCEDURE command2.Click
		CLOSE TABLES
		THISFORM.RELEASE()
	ENDPROC


ENDDEFINE
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform