Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid columns controlSource
Message
De
16/07/2000 22:23:17
 
 
À
14/07/2000 21:46:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00392786
Message ID:
00393089
Vues:
17
>I have a form with a grid on it. I used the builder to populate the columns on the grid.
>
>The grid worked fine, but I was unable to find any properties on the grid that matched up specific columns to specific fields in the child table. I scratched my head and gave up trying to figure out how it worked...until...
>
>I needed to delete the first column. Now everything has shifted in a weird (and unusable) manner. I have tried manually setting the columns' controlSources, and have tried setting the controlSource in each textControl (or whatever control) in each column to the correct field in the child table, all to no avail.
>
>Do I have to rebuild my grid from scratch with the builder? Is deleting a column the big no-no?



Um... if you want to delete First Column without Losing any coding inside the Grid Object,
(including column, header, controls in columns), I suggest you to do is:

1) Backup the Forms... (^-^)
2) RightClick the Grid then Select Edit
3) Drag the Column1 Header to the RightMost (i.e. Last Column), Drag and Wait Until it fly to last Column...
4) At Property Window, Change the Grid.ColumnCount Value to less one...
i.e. If the ColumnCount is 12, then key-in 11 with return..

After the above action, you will find that there will be 11 columns and the Last one (Original is the First column)
is killed!! That is, the Column is killed and any code put there would be vanished!

The fact: if you forgot to drag the Column (Step 3), you will lose the last column..
Thus, you need to ensure that the unwanted column is drag to the last column position before to change the ColumnCount Value

Then, you will wonder that the grid has shift the Columns Name Value by one...
i.e. the First Column Name of after kill grid will be Column2 and it will make you hard to remember...

You can now write a prg to Correct the Column Name..

In below example, save it as renColName.prg
Then, At Command Window, key-in:
On Key Label F11 Do renColName.prg

Then, Open the Form in Form Designer, and select the grid.
Now, Key-in F11 and the renColName.prg will Rename All Column Name in Grid with easy!! :)

After successful rename, at command window to reset the F11 short-cut:
On Key Label F11


* Example: renColName.prg
* Rename the Column.Name as the ColumnOrder 

Local grdObjCount, grdSelect[1]

grdObjCount = ASelObj(grdSelect)
If grdObjCount <> 1
	Messagebox([You should select ONE grid to do this rename Column Name prg], 16, [Rename Stop!])
	Return
endif

if grdSelect(1).class <> [Grid]
	Messagebox([You should select grid to do this rename Column Name prg, not other object], 16, [Rename Stop!])
	Return
endif

For ix = 1 to grdSelect(1).ColumnCount
	grdSelect(1).Columns[ix].Name = [Column] + Alltrim(Str(ix))
EndFor

Messagebox([Rename Column Name is Done!!], 64, [You've done a good job!])



There is a similiar class/form can be download in File Section but it does NOT rename all Column Name
with one step.. (a list of Column to rename one-by-one.. of cos already faster than property window rename)

If you can understand the usage of ASelObj above, you can make any easy program to handle your
form object during Design in Form Designer!!
In Chinese Old Saying, It is poor if a shoemaker who is shoeless...




Well, the above manual step is to make you understand the Usage of ColumnCount in grid..
Of cos, you can make another prg with similiar coding the Rename All ColumnOrder of grid and
then reassign the ColumnCount... and Finally use a For-loop again to rename all column Name...
Actually, if you understand the coding, you need about to make 20-30 Line Of Code and do your request quickly..
but you need to afraid you have key-in double and delete more than 1 column...
That's why I suggest you to do it manually!


p.s. Coding is Fun, enjoy your programming life with smile!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform