Microsoft KB Archive/191997

= BUG: BackColor/ForeColor of Grid Not Carried Over to Subclass =

Article ID: 191997

Article Last Modified on 8/19/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q191997



SYMPTOMS
When changing the BackColor or ForeColor properties of a grid class's header in the Class Designer to some other color, the grid header remains in the default color after subclassing the class on to a new form.



RESOLUTION

 * Create the grid class definition through code, then add the grid to the form using the AddObject method. Please see step 1 in the Workaround section for further instruction.

-or-
 * Change the Backcolor or ForeColor properties of the Header in the subclassing grid.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



MORE INFORMATION
The behavior as described in the SYMPTOMS section, does not occur if the grid is created through code rather than using the class designer.

Steps to Reproduce Behavior
 Create a Grid class in Class Designer, named the class mygrid and save the class in myclass library. Change the ColumnCount property of the grid to 1. Go to the header object of the grid and change the following properties of the header object:

BackColor = 255,0,0 ForeColor = 0,255,0

 Close the class designer. Create a new form in a form designer, named myform. Add the myclass class library to the Form Controls toolbar.</li> Select mygrid from the toolbar and place it onto the form.</li></ol>

The Header of the grid object shows up as default color, which is gray for the backcolor and black for the forecolor.

Workaround
<ol>  Create a program (.prg) named Gridclass.prg and put the following code in the .prg file: DEFINE CLASS grid1 AS Grid ADD OBJECT column11 AS column1 ENDDEFINE

DEFINE CLASS column1 AS Column Width = 120 ADD OBJECT header11 AS header1 ENDDEFINE

DEFINE CLASS header1 AS Header ForeColor = rgb(0,255,0) BackColor=rgb(255,0,0) ENDDEFINE </li>  Create a form and in the Init event of the form place the following code: SET PROCEDURE TO gridclass.prg Thisform.AddObject("mygrid","grid1") Thisform.mygrid.Visible = .T.                           </li> Run the form and the grid header shows up with the backcolor and forecolor you expect.</li></ol>

Additional query words: kbVFp600bug kbVFp500abug kbCtrl kbContainer kbDesigner kbOOP

Keywords: kbbug kbnofix kbcode KB191997

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.