Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building FoxyClasses LocatorGrid at runtime
Message
From
10/03/2017 11:24:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/03/2017 08:40:22
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01648879
Message ID:
01648907
Views:
71
>>>Has anybody written code to create the FoxyClasses' LocatorGrid at runtime? I'm trying to do so and running into some issues. Wondering whether anyone has made this work?
>>>
>>>Tamar
>>
>>Yes, It is really straightforward, ie:
>>
>>
>>Public oForm
>>oForm = Createobject('sampleForm')
>>oForm.Show()
>>
>>Define Class sampleform As Form
>>	Height=600
>>	Width = 800
>>	Add Object myButton As CommandButton With Caption="Create Grid"
>>	Add Object myContainer As Container With Top=30,Height=770,Width=800, Anchor=15
>>
>>	Procedure myButton.Click
>>		Thisform.myContainer.Newobject("myLocator","locatorgrid", "d:\foxyclasses\classes\grids.vcx","",;
>>			"* from (_samples+'data\customer')")
>>		With Thisform.myContainer.myLocator
>>			.Height = Thisform.myContainer.Height
>>			.Width = Thisform.myContainer.Width
>>			.Anchor = 15
>>			.Visible = .T.
>>		Endwith
>>	Endproc
>>Enddefine
>>
>>
>
>Thanks. I'm doing it by adding the grid in the form's Init method (because I need to pass in the field list and other stuff). The grid came up, but it appears that something didn't work right. I don't get controls in the columns named "myHeader" and "myText", only the defaults. Here's the code I put in the grid subclass's Init:
>
>
>* Modified 9-March-2017 by TEG
>* Changing parameters, so we can build grid on the fly. 
>LPARAMETERS tcFieldList, tcTable
>*!*	Lparameters cSQL, cOrgSource
>IF PCOUNT() < 2
>	DO Error WITH "Cannot set up picklist without field list and table name"
>	RETURN .F.
>ELSE 
>	This.plFields = m.tcFieldList
>	This.cMainTable = m.tcTable
>ENDIF
>
>This.oFieldList = NEWOBJECT("colBase","picsbase.vcx")
>IF This.SetupGrid()
>
>	DODEFAULT('', '')
>	This.FormatGrid()
>	
>ELSE
>	RETURN .F.
>ENDIF 
>
>
>My custom SetupGrid method sets the cSQL property. Hmm, just hit me that I should probably pass .F. or omit the params in DODEFAULT. I'll try that.
>
>Tamar

If cSQL is not known beforehand, then when you are ready:
with yourLocatorGrid
   .cSQL = "fieldList from ..."
   .lKeepFormat = .T. && If you have preset columns that you want the format preserved - might be already set to true 
   .Init() && then you need to call init
endwith
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform