>We have added a property and some code to all of our text boxes and would like to do the same with the text boxes in our grids. The text boxes were easy, just make the changes to the base class and over a thousand text boxes in hundreds of forms were changed.
>
>We would like to do the same in all our grids but I sure of the best way to do it. I can add the property to each column textbox using addproperty in a loop in the grid init but how do I add code to each text box without editing every column of every grid?
>
>I thought about writing a builder (more like a chainsaw prg) that would hack through every grid in every .scx and add code to the text box click events but I'm not sure how to focus on just the column textboxes though I have ideas.
>
>Is there a way to automate changing out the default text box and replacing it with the desired one from my class?
>
>Mostly, at this point, I'm looking for some suggestions, advice, ideas.
>Thanks.
John,
You can look at it as a two part problem. What would I do with the grids that have been already designed and what would I do for new grids. For new grids you could simply use member* properties available in VFP9 (or like me have your own custom grids that build themselves with custom controls).
For existing ones you can't simply change with a custom grid building its own members because then you'd lose already coded methods if any. So for existing an 'in place' class changing is better.
Now your current problem is existing grids and you'd be more than happy if you could change all textboxes with your textbox class, right? Go for a hack! It's simple and fast (ie: 100 forms would be done in less than 100 seconds). Backup and do it with courage:)
lcMyTextBoxClassName = "myTxtClass"
lcMyTextBoxClassLib = "c:\my libs\myClassLib.vcx"
lcFormsFolder = getdir()
for ix=1 to adir(aForms, addbs(m.lcFormsFolder)+'*.scx')
use ( addbs(m.lcFormsFolder) + aForms[m.ix,1] )
replace class with m.lcMyTextBoxClassName, ;
classloc with m.lcMyTextBoxClassLib ;
for lower(baseclass) == 'textbox' and empty(classloc)
use
compile form ( addbs(m.lcFormsFolder) + aForms[m.ix,1] )
endfor
You can extend the code to do that only for textboxes which are in a grid (check parent), create a log of what have changed, what were already edited properties/methods etc.
Cetin