Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid column width ignored
Message
From
22/03/2006 09:36:13
 
 
To
14/03/2006 02:02:09
Yh Yau
Ingenuity Microsystems Sdn Bhd
Kuala Lumpur, Malaysia
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01104035
Message ID:
01106614
Views:
17
Write the column width (& other pertinent info like columnorder) to MyFormMyGrid.Log and use it at MyGrid.Init?
* Grid's Destroy method

Local cString As String
cString = ''

For i = 1 To This.ColumnCount
&& 1 = Order, 2 = Width
	cString = cString + Alltrim(Str(This.Columns[i].ColumnOrder)) + Chr(13)
	cString = cString + Alltrim(Str(This.Columns[i].Width)) + Chr(13)
Endfor

cFile = "Logs\" + Thisform.Name + This.Parent.Name + This.Name +  ".log"		&& Write the default file for column width
If Not File(cFile) And Not Empty(cString)
	=Strtofile(cString,cFile)
Endif

If Type('THIS.cGridLog') = 'C' And Not Empty(cString)					&& Write the users settings
	=Strtofile(cString,This.cGridLog)
Endif
In the grid's intit you can then do something like this
With This
	If .ColumnCount > 0
		Local Array GridOrder(.ColumnCount)
		Local lnCounter As Integer


		.cGridLog = Thisform.cLogDir;
			+ Thisform.Name + .Parent.Name + .Name +  ".log"

		If File(.cGridLog)							&& The user has already been in and out of this screen
			lcGridLog = .cGridLog
		Else										&& Try to use the default grid log if any
			lcGridLog = "Logs\" + Thisform.Name + .Parent.Name + .Name +  ".log"
		Endif

		If File(lcGridLog)
			Alines(GridOrder, Filetostr(lcGridLog))
			lnCounter = 1
			For i = 1 To .ColumnCount
				Try
					.Columns[i].ColumnOrder		= Val(GridOrder[lnCounter])
					lnCounter = lnCounter + 1
					.Columns[i].Width			= Val(GridOrder[lnCounter])
					lnCounter = lnCounter + 1
				Catch
				Endtry
			Endfor
		Endif


		.SetAll('Bound',.T.,'Column')
Endwith
That way, your users can muck about with columnorder and width and you'll never have to worry if it looks good, it'll be their responsibility.

HTH
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform