Microsoft KB Archive/171746

= PRB: ListBox/ComboBox Picture Won't Display If Defined in Class =

Article ID: 171746

Article Last Modified on 12/11/1999

-

APPLIES TO


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

-



This article was previously published under Q171746



SYMPTOMS
When running Visual FoxPro under Windows 95, a class based on either a list box or a combo box that sets the Picture property in the class, does not display the picture either in the Form Designer when you add the class to a form, or when you run the form. If FoxPro is running under Windows NT 4.0, the picture does not appear in the Class Designer either.



RESOLUTION
This article includes two workarounds. The first adds a new property to the class that sets the Picture property to the new property. The second sets the Picture property in the form after the class is added. Both methods assume that the class has been created following steps 1-3 in the Steps to Reproduce Behavior section below.

Method 1
  Open the class in the Visual Class Designer. Either by selecting Open from the File menu and then clicking Visual Class Library as the file type or enter the following command in the Command window: MODIFY CLASS list OF test.vcx  Create a new property for the class by selecting New Property from the Class menu. Enter the property name; cPicture, for example. Click Close. Locate the Picture property on the Property Sheet. Copy the path to the graphic and file name from the Picture property and paste it to the new cPicture property.  In the Init of the class, add the following code: This.Picture = This.cPicture  Close and save the class. Run the form. The picture should appear next to each row in the list.</ol>

NOTE: If any code or comments are added to the Init of the List1 class on the form, add the DODEFAULT statement to the Init of List1 to ensure that the parent class Init code is also executed.

Method 2
<ol> Create a form. Using the Form Controls Toolbar, click the View Classes button and select Add. Add the test class library. Click the list class and drop it onto the form.</li>  In the Init of the form, enter code similar to the following: Thisform.List1.Picture = ; "c:\vfp5\samples\graphics\bmps\assorted\bell.bmp" </li> Save and run the form.</li></ol>

This method is similar to explicitly setting the Picture property of List1 of the Property sheet to the graphic.

<div class="status_section">

STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol>  Create a new class by either selecting New from File menu then selecting Class or enter the following code in the Command window: CREATE CLASS list AS listbox OF test.vcx </li>  Set the Picture property of the ListBox to a graphic: c:\vfp5\samples\graphics\bmps\assorted\bell.bmp NOTE: In Windows 95, the picture is visible in the Visual Class Designer. </li> Save and close the class.</li> Create a form. Using the Form Controls toolbar, click the View Classes button and select Add. Add test.vcx. Click the list class and drop it onto the form.

NOTE: The picture is not visible in the list class on the form.</li> Right-click on the form to display the short-cut menu, and select Data Environment.</li> Add the customer table from the \VFP5\Samples\Data directory, then click Close.</li> Change the RowSource property of List1 to customer.contact and the RowSourceType property to 6 - Fields.</li> Save and run the form.</li></ol>

<div class="references_section">