Hans L


I have made my own grid base class with 9 columns. When I create a grid based on this class, and I try to reduce the number of columns, I get an error message saying "Member COLUMN# is a class member" (# being the umber just above the one to which I want to change; if I want to go from 9 to 7, # = 8).

What am I missing, believing this would work

Hans L

PS. I wanted to make every column heading centered vertically/horizontally and bold. With column # = -1, this cannot be done, as far as I understand (no columns in Propoerties).



Re: Grid class

AndyKr


The reason is that the class defines the number of colums. You cannot change a class definition in an instance - that is the whole point of inheritance. An object is NOT a copy of the class, but is actually a reference to it! So if you define 9 columns, then you cannot create a grid based on that class that has only 8 (you CAN increase the number because you get the original 9 PLUS some local ones) but you cannot reduce the number that are inherited.

A better design is to define your grid class with NO columns and simply set the colulmn count property each time you need it. Use the grid builder to set the grid up rather than trying to define it all in the class.







Re: Grid class

Hans L

Thanks for your explanation, Andy.

Hans L





Re: Grid class

Hans L

In "1001 Things You Wanted to Know About Visual FoxPro", c2000, page 163 ("How do I highlight the current grid row"), it says:

"Fortunately, it is a fairly simple matter to add this functionality to your base class grid."
...
To change the highlight when the current grid row changes, this code is needed in the When method of each control in every column of the grid:"

Am I right in assuming that in a "normal" grid, "each control in every column of the grid" refers to the text box controls (but not header controls) in the columns And, if that is correct, the code in question cannot be entered into my base class grid (or base grid class) if I choose, as you suggested, to set the number of columns to -1

Hans L




Re: Grid class

Hans L

And when I set the When to .F. in my Grid class, and, for instance, Valid to .T., and I then look at an instance of the Grid class, Valid shows "Inherited ...", but When shows "User Procedure"! Does anyone know what that is all about

Hans L




Re: Grid class

CetinBasoz

1) You can decrease columncount to 8,7 ... in code.

2) You can use SetAll() to assign properties to all member controls of a container type class (like a grid).

3) You can't set when/valid to values like .f./.t. They are not properties but procedures. You can however return values of .f./.t. from their code.

If it's saying "Inherited ..." then that means you didn't write any code but the class from which you created the instance had code in that method (otherwise just Default for built-in VFP code). When it says "User procedure" then that means you have code overriding class' code in instance. Doubleclick to see the code you have written (warning: even spaces that you might somehow left there counts as code. If you don't see any code and sure that you don't want to have instance code there then in PEM sheet, right click and select "reset").

 "Am I right in assuming that in a "normal" grid, "each control in every column of the grid" refers to the text box controls (but not header controls) in  the columns   And, if that is correct, the code in question cannot be entered into my base class grid (or base grid class) if I choose, as you suggested, to set the number of columns to -1 "

No you are not right in your assumption. A column.controls collection has header and other controls in column (typically Controls[1] is the header and Controls[2] is the textbox - unless edited).

I don't know what code are you trying to add but probably it can be added to base class. Many grid aspects are controlled directly at grid level.You can also add your own column,header, textbox ... controls.





Re: Grid class

Hans L

> 1) You can decrease columncount to 8,7 ... in code.

Okay, but I need it when designing (e.g. in Project manager)

> 2) You can use SetAll() to assign properties to all member controls of a container type class (like a grid).

Okay, but again, I need it as design time (e.g. in Project manager)

> 3) You can't set when/valid to values like .f./.t. They are not properties but procedures. You can however return values of .f./.t. from their code.

1001 Things ... FoxPro, "How do I highlight the current grid row", page 164: "We also need to set the grid's lAbout2LeaveGrid property to true in its Valid method and to false in its When."

> If it's saying "Inherited ..." then that means you didn't write any code ...

I re-entered text and everything turned out okay after that.


"Am I right in assuming that in a "normal" grid, "each control in every column of the grid" refers to the text box controls (but not header controls) in the columns And, if that is correct, the code in question cannot be entered into my base class grid (or base grid class) if I choose, as you suggested, to set the number of columns to -1 "

> No you are not right in your assumption. A column.controls collection has header and other controls in column (typically Controls[1] is the header and Controls[2] is the textbox - unless edited).

On page 163, it says : "To change the highlight when the current grid row changes, this code is needed in the When method of each control in every column of the grid: [code]

I just assumed that "header" did not apply here (I now know it does not have a When method), but only the text boxes of the grid columns (and, of course, any other control that had been placed into the grid).

I think I understand this now. Thank you for your clarifications.






Re: Grid class

AndyKr

> 1) You can decrease columncount to 8,7 ... in code.
>> Okay, but I need it when designing (e.g. in Project manager)

As I told you, you cannot do this - Cetin is, of course, correct that you can change it at run time in code. But at design time you can't.

> 2) You can use SetAll() to assign properties to all member controls of a container type class (like a grid).
>> Okay, but again, I need it as design time (e.g. in Project manager)

And the only way to do that is to use a builder - which is just code that runs at design time. Look at the ASelObj()  function - it will allow you to get a reference to an object at design time and then you can manipulate it in code.

> 3) You can't set when/valid to values like .f./.t. They are not properties but procedures. You can however return values of .f./.t. from their code.
>>1001 Things ... FoxPro, "How do I highlight the current grid row", page 164: "We also need to set the grid's lAbout2LeaveGrid property to true in its Valid method and to false in its When."

 I don't understand why you are quoting our book here (and yes, I am one of the authors of that book!) You have to add code to do that - In the VALID you need "This.lAbout2LeaveGrid = .T." and in the WHEN, you need "This.lAbout2LeaveGrid = .F." and code only executes at RunTime!

> If it's saying "Inherited ..." then that means you didn't write any code ...
>> I re-entered text and everything turned out okay after that.

But that means that you over-wrote anything that was in the SuperClass - you may as well not bother creating the class if you are going to do everything in every instance. (Do you actually understand how inheritance works in VFP )

>> On page 163, it says : "To change the highlight when the current grid row changes, this code is needed in the When method of each control in every column of the grid:  [code]
>>I just assumed that "header" did not apply here (I now know it does not have a When method), but only the text boxes of the grid columns (and, of course, any other control that had been placed into the grid)

Again I am very confused trying to understand what you are thinking. There are two unrelated items here. The column that you see in the Grid - which is what the text you quote refers to, and the Column Object that exists in VFP, which is what Cetin is referring to. The Object has a "controls" collection which defines the class of all obejcts in the column, the Header, the Textbox and any other controls that may have been added. This has nothing to do with the code that you add to any control that you want to display IN the column (which is what the text refers to).

Since you seem to be fond of quoting our book, how about re-reading the paragraph at the bottom of Page 1 where it states:

As we have already said, this book will not teach you to use Visual FoxPro,   it assumes you have a reasonable degree of comfort with the basic operation of the VFP Database and Command Language, and with the basic principles of Object Oriented Programming.   We would expect that you will have read, and used, such excellent and useful references as Whil Hentzen¡¯s ¡®Programming VFP¡¯; ¡®The Revolutionary Guide to VFP OOP¡¯ by Will Phelps, Andy Kramek and Bob Grommes and, of course, the indispensable ¡®Hacker¡¯s Guide to VFP¡¯ by Tamar Granor and Ted Roche.

I suspect that you may have skipped one or more of those volumes....






Re: Grid class

Hans L

>1) You can decrease columncount to 8,7 ... in code.

>> Okay, but I need it when designing (e.g. in Project manager)

>>>As I told you, you cannot do this - Cetin is, of course, correct that you can change it at run time in code. But at design time you can't.

What I meant to say was that there are things I believe that beginners like me *have to see* at design time, even if the same effect can be achieved by code.

> 2) You can use SetAll() to assign properties to all member controls of a container type class (like a grid).
>> Okay, but again, I need it as design time (e.g. in Project manager)

>>> And the only way to do that is to use a builder - which is just code that runs at design time. Look at the ASelObj()  function - it will allow you to get a reference to an object at design time and then you can manipulate it in code.

Again, I acknowledged by "Okay" that I certainly believed what Cetin said, but I wanted to emphasize  that I personally need to see things at the design phase until I become experienced. I will look at ASelObj().

> 3) You can't set when/valid to values like .f./.t. They are not properties but procedures. You can however return values of .f./.t. from their code.
>>1001 Things ... FoxPro, "How do I highlight the current grid row", page 164: "We also need to set the grid's lAbout2LeaveGrid property to true in its Valid method and to false in its When."

 I don't understand why you are quoting our book here (and yes, I am one of the authors of that book!) You have to add code to do that - In the VALID you need "This.lAbout2LeaveGrid = .T." and in the WHEN, you need "This.lAbout2LeaveGrid = .F." and code only executes at RunTime!

This is what I have done (now :-).  I think I tried to set the Valid and When to only .T. and .F. first.  Opppps! 

> If it's saying "Inherited ..." then that means you didn't write any code ...
>> I re-entered text and everything turned out okay after that.

>>>But that means that you over-wrote anything that was in the SuperClass - you may as well not bother creating the class if you are going to do everything in every instance. (Do you actually understand how inheritance works in VFP )

I did have a space in one place in the instance, which was a *mistake*!!!!!  But in the class, I could not see any mistake (although it was probably there), but when I deleted all text and retyped it, everything was suddenly right. Yes, again, probably something I did, but did not know I had done.
And, yes, I do understand how inheritance works in VPF.

>> On page 163, it says : "To change the highlight when the current grid row changes, this code is needed in the When method of each control in every column of the grid:  [code]
>>I just assumed that "header" did not apply here (I now know it does not have a When method), but only the text boxes of the grid columns (and, of course, any other control that had been placed into the grid)

>>>Again I am very confused trying to understand what you are thinking. There are two unrelated items here. The column that you see in the Grid - which is what the text you quote refers to, and the Column Object that exists in VFP, which is what Cetin is referring to. The Object has a "controls" collection which defines the class of all obejcts in the column, the Header, the Textbox and any other controls that may have been added. This has nothing to do with the code that you add to any control that you want to display IN the column (which is what the text refers to).

Okay, I will add the code in question to Valid and When in the textbox in each column and see what happens.

>>>Since you seem to be fond of quoting our book, how about re-reading the paragraph at the bottom of Page 1 where it states:

>>>As we have already said, this book will not teach you to use Visual FoxPro,  it assumes you have a reasonable degree of comfort with the basic operation of the VFP Database and Command Language, and with the basic principles of Object Oriented Programming.  We would expect that you will have read, and used, such excellent and useful references as Whil Hentzen¡¯s ¡®Programming VFP¡¯; ¡®The Revolutionary Guide to VFP OOP¡¯ by Will Phelps, Andy Kramek and Bob Grommes and, of course, the indispensable ¡®Hacker¡¯s Guide to VFP¡¯ by Tamar Granor and Ted Roche.

>>>I suspect that you may have skipped one or more of those volumes....

Yes, I have. Let me briefely mention that I am learning by doing, with the help of "The Fundamentals ..." and ""1001 Things ...". I can't learn by just reading.  I took a course at Columbia U in NYC in the 80s on dBase II, went home, found that the course was (for me) useless, bought a book with all comments etc. in alphabetical order, and created a management system for PROCEEDINGS OF THE IEEE (a very prestigious journal of which I was the editor)  that was much more sophisticated than anything I, at my present level of knowledge, can do with VPF9.  I have a number of minor apps in VPF that I have developed.  I later worked together with a programmer, but he was of the type "Well, next Friday, I will ...".  We parted ways.  So here I am, doing it myself, in spite of not being talented.  Now, if you want to direct me to more of a beginners forum, I will receive that very positively, and get back here only when I have more experience.  I know how frustrating it can be with people who are balancing on the edge of  ignorance.

Hans L





Re: Grid class

AndyKr

>> Now, if you want to direct me to more of a beginners forum, I will receive that very positively, and get back here only when I have more experience.  I know how frustrating it can be with people who are balancing on the edge of  ignorance.


Not at all please ask away I wasn't trying to be sarcastic, just trying to say that KiloFox (1001 Things...) is probably NOT the best source for you based on the level of experience you are showing us. I would stongly suggest taking a look at http://www.hentzenwerke.com/catalog/fund6.htm (Fundamentals: Building Visual Studio Applications on a Visual FoxPro 6.0 Foundation). It is an old book and slightly out of date, but does cover the basic tools and techniques well. It's only available in E-Book form now but you may find it more immediately useful than KiloFox.

But do not be afraid to ask anything - we are only too pleased to help where we can but you do need to give us as much information as possible.

 

 






Re: Grid class

Hans L

Thanks, Andy, for the book tip. I will also look at the other books you mentioned. And I will ask more -- the first one tomorrow morning (oy vey! :-)