Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Programmatically set column widths in dynamic gri
Message
 
To
13/08/2002 15:53:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00689312
Message ID:
00689321
Views:
32
This message has been marked as a message which has helped to the initial question of the thread.
You can use FONTMETRIC() function to determine the Avg Width of a Font. Multiply by LEN(Field). That gives you column width that you can use.

>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
>
- Jayesh
Previous
Reply
Map
View

Click here to load this message in the networking platform