Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid columns controlSource
Message
From
18/07/2000 23:16:37
 
 
To
18/07/2000 10:23:01
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00392786
Message ID:
00394169
Views:
14
>Hello Terence,
>
>Our home office is in HK.
>
>The grid builder actually did its job correctly. It saves a few minutes on setting up the grid. It doesn't make as many assumptions as the larger wizards do.
>
>My problem is that the controlSource of each column is being lost when the form is loaded (happens with manually created grid also). I can programmatically set the controlSources for the columns; take a look at the rest of the discussion in this thread if you are interested...



Hi all!

Well, losing everything on grid or listbox, combox would have many cases...
Actually, I wondered those poor Fact and cry in 2 years ago!!!

There is a bwtable.zip (Browsing data in Current Directory with grid in File Section...) made by me!
It gives the way to handling those losing coding situation..

Poor Facts on using CreateObject, AddObject but not normal DO FORM on class with grid, listbox, combox, especially on grid:
1) It will Take the CURRENT WORKING AREA on Source and even Ignore your assignment Coding!! Cry a lot!
2) All Column objects and also their child will be reset!! Losing coding, controlsource.... everything!
3) If there is NO CURRENT WORKING AREA, it make a Open DBF file dialog and ask you can give a working area!!




The first point make me very angry!! Computer don't work as my coding told!! What a Computer language!!!
If you want to try how the poor facts do:

1) make a form class named fTest and give a grid on it with recordsource "TableA"
2) at Ftest.Load, you need to put the coding on loading DE:
* Ftest.load
If !used("TableA")
  Use TableA again in 0 order tag KeyA shared
endif

=CursorSetProp("buffer", 5, "TableA")

If !used("TableB")
  Use TableB again in 0 order tag KeyB shared
endif

=CursorSetProp("buffer", 5, "TableB")

SELECT TABLEB    && Change the Current Work Area to TableB, this make you CRY!!
3) make a form to call the class:

Set Classlib to myCls.vcx additive
public fTest1
fTest1 = CreateObject("fTest")
fTest1.Show



This's all, you will find that the Grid MUST show TABLEB data even you adding coding on Grid.Init:

This.Recordsource = ''
This.ColumnCount = -1
This.Recordsource = "TableA" && unbelievable, this line of code is ignored!

It still show TableB data and Ignore your last coding on assigning Recordsource!!! Angry!? /._.\"
Of cos, all your controlsource assignment is lost!!




Now, no time to angry, what you need to do:

At Grid.Init:

Select MyBaby && or TableA, this Line is Everything!!
* Set Field to field2, field3, field4, field5... && this line is optional if you really want to skip 1st Field!

This.ColumnCount = -1
* This.Recordsource = "MyBaby" && Actually, even you don't add this line, it still work, add for easy comprehensive! ;o

For iCount = 1 to This.ColumnCount
This.Columns[iCount].RemoveObject("text1")
This.Columns[iCount].AddObject("text1", "txt")
This.Columns[iCount].text1.Visible = .T. && all new addobject default is invisible, notice it!
This.Columns[iCount].text1.BORDERSTYLE = 0
This.Columns[iCount].text1.SPECIALEFFECT = 1
This.Columns[iCount].SPARSE = .F.
EndFor




Where txt is a your self-defined textbox which used in grid!
Benefit: you surely not using any coding on textbox in grid as the coding is kept in the class is put the class to use in run-time!
Of cos, you can also make header class in CODING only or other combox class for grid use..
and do RemoveObject & AddObject to make it new!




For similar job to combox and listbox created by CreateObject, AddObject Function,
it will get current work area as rowsource but as there is not much child object inside it, the problem you get will be less.

From this learning, I wonder how VFP handle your coding, DE is most important, forms and controls are just the way to give
you the current record data! If current working area is taken wrong or losing cursor Relationship as multi-open-close
work area... Your application will become a unbelivable rubbish!!


That's why, ppl here teach you don't use formset if possible and use Private Data session if possible to prevent the above
out of control situation!! That's also why I ask you to show the first column for cross-check if possible, although the outlook is poor!

Tips on open table in coding:

Select 0 && start a new empty work area
Use ....




Sample code on corrupting DE relationship if don't use New work area:

Use TableA
Browse
Use TableB
Set View On && only work within VFP

You will wonder that the TableA is closed as TableB open instead!!




Get it? try out the above example to ensure you understand what I say!!
The above observation waste me 4-6 months two years ago to find it... especially ignore coding part.. /._.\"
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform