Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid
Message
From
03/11/2003 12:29:05
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
03/11/2003 11:44:54
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Re: Grid
Miscellaneous
Thread ID:
00845337
Message ID:
00845681
Views:
20
>Cetin,
>
>If one puts the RecordSource SQL statement in the Init() of the grid as you suggest, are you then going to have to add the appropriate columns in code?
>
>I can think of no way to add the columns in the property sheet and have them instantiate without a recordsource already defined.
>
>I'm curious how you do this.
>
>Regards,

Jim,
You might :
-add the columns in code
-Add at design time
-Let the grid build itself

With no recordsource around (at designtime) you can set the columncount to say 3 and go and set column controlsources as :
myAlias.f1
myAlias.f2
myAlias.f3

No matter what the actual recordsource is and provided myAlias is accesible at runtime this would work.

Also this would work (keep design time format, change source) :

myGrid.recordsource = ''
* select or via other means create a cursor named crsMyCursor
* You might be stumped with empty headers
* and excess columncount with unexpected formatting
* If you didn't do anything and a cursor was around
* when grid inited
myGrid.Recordsource = 'crsMyCursor'

Or this (let grid build itself from scratch) :

myGrid.recordsource = ''
myGrid.Columncount = -1 && This is like when you first drop a grid on form
* select or via other means create a cursor named crsMyCursor
myGrid.Recordsource = 'crsMyCursor'


Grids have a great affinity to snap to the cursor they find first if no recordsource exists. This matters for you to decide whether you'd reset columns or build them in code or not.

.Columncount = -1 && A new grid dropped on form - reset columns
.Recordsource = 'whatever'

Fcount() and fields order in 'whatever' determine the layout of the grid.

If your grid was a special one say having custom column, textbox controls then setting .Columncount = -1 wouldn't be what you want. Instead you'd use :

.Recordsource = ''
*..
.Recordsource = '.....'

Then either :
.Columncount = 4 && 4 is a sample
Or :
Work with columns individually in code.
Well plain English it's getting messy :) Very little code to show .Columncount=-1 effect :
Local oForm1, oForm2
oForm1 = Createobject('myForm1')
oForm1.Show(1)
oForm2 = Createobject('myForm2')
oForm2.Show(1)


Define Class myForm1 As Form
  DataSession=2
  Add Object myGrid As Grid

  Procedure Load
  Use customer
Endproc

  Procedure Init
  With This.myGrid
    .RecordSourceType = 4
    .RecordSource = 'select * from ordItems into cursor crsOrders'
  Endwith
Endproc

  Procedure QueryUnload
  Clear Events
Endproc
Enddefine

Define Class myForm2 As Form
  DataSession=2
  Add Object myGrid As Grid

  Procedure Load
  Use customer
Endproc

  Procedure myGrid.Init
  With This
    .ColumnCount=-1
    .RecordSourceType = 4
    .RecordSource = 'select * from ordItems into cursor crsOrders'
  Endwith
Endproc

  Procedure QueryUnload
  Clear Events
Endproc
Enddefine
PS: Code is just the tip of iceberg:)
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
Next
Reply
Map
View

Click here to load this message in the networking platform