Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using forms with classes
Message
From
13/12/2003 09:15:47
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/12/2003 05:59:11
Paul Trimming
Lonely Pilgrim Shareware
Merstham, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00858883
Message ID:
00858894
Views:
14
This message has been marked as a message which has helped to the initial question of the thread.
>Hello,
>
>I am a new Foxpro programmer, unused to using classes. I have saved a form with a grid as a class, but am having difficulty in getting it to display data. I have written the following code:
>
>IN THE MENU
>set classlib to frmclass additive
>test2 = createobject("frmgridform")
>test2.show
>
>IN THE TEST2 INIT FORM METHOD
>WITH THISFORM.Grid1
>* update the grid record / control source
> .RECORDSOURCE = THISFORM.tempfileAlias
> .column1.CONTROLSOURCE = exp1table1.fldnumber1
> .column2.CONTROLSOURCE = exp1table1.fldpet
>ENDWITH
>
>What I don't know is how to open the tempfileAlias database (or is it cursor?), and assign a table and its fields to the grid. I would be very grateful for the code to do this, as well as comments on if I am instantiating the class correctly in the first place.
>
>Many thanks,
>Trimtrom

Read reply(ies) in other forum too.
Here you changed the question a bit hence the solution changed a bit.
Are there only 2 controlsources ? If yes probably recordsource would also be "exp1table1" :
*form.init
WITH THISFORM.Grid1
  .RecordSource = '' && Keeps formatting
  if !used("exp1table1")
     use (THISFORM.tempfileAlias) alias "exp1table1" in 0
  endif
* update the grid record / control source
   .RECORDSOURCE = "exp1table1"
   .column1.CONTROLSOURCE  = "exp1table1.fldnumber1"
   .column2.CONTROLSOURCE  = "exp1table1.fldpet"
ENDWITH
THISFORM.tempfileAlias might be anything and this code would fail. ie: if that's really an alias and not the table/cursor name then use line would error. If that's something to be filled upon creation of class (with no meaningfull default value and/or datatype in class) then again would fail for you didn't set it. IOW it's hard to determine what the actual code should be.
Anyway code in other forum should make things clear for you.
PS: If you're a newcomer why are you using class based forms. IMHO class based forms don't have a neat superiority over non class based ones.
Cetin
Ç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
Reply
Map
View

Click here to load this message in the networking platform