Microsoft KB Archive/813561

= BUG: ListView Control Does Not Render Correctly When You Change CheckBox Property to TRUE and the View Property is SmallIcon or List =

Article ID: 813561

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft .NET Compact Framework

-



SYMPTOMS
In Microsoft .NET Compact Framework, when you set the View property to the SmallIcon member, or when you set the View property to the List member, the ListView class control does not correctly draw itself, and the CheckBoxes property changes its value to TRUE.

The behavior of the View property varies according to the setting:
 * If you set the View property to SmallIcon, the item check box is drawn under the text of the preceding item.
 * If you set the View property to List, the text of the items does not display completely.



CAUSE
The problem occurs because the ListView control does not correctly draw itself.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



WORKAROUND
To work around this problem, you must force the ListView control to recalculate and then redraw its content.

Change the View property of the control. After you set the Checkboxes property of the ListView control to TRUE, change the View property of the control.

For example, if the ListView control is set to TRUE, change it to LargeIcon, and then reset the View property to its original value (for example, SmallIcon).

The following code describes the problem: //The ListView CheckBoxes property is being reset. listView1.CheckBoxes = !listView1.CheckBoxes; //Set the ListView View property to LargeIcon. listView1.View = System.Windows.Forms.View.LargeIcon; //Set the ListView View property to its original value, that is, SmallIcon, to force the control to redraw. listView1.View = System.Windows.Forms.View.SmallIcon;

Note The workaround introduces additional overhead when you redraw the ListView control.



Steps to Reproduce the Behavior
 Create a new Smart Device Application in Microsoft Visual Studio .NET 2003. Drag a ListView control from the Device Controls tab to the Toolbox. If you cannot see the Properties window, right-click the ListView control, and then click Properties. In the Properties window for the ListView (ListView1) control, set the View property to SmallIcon. In the Properties window for the ListView (ListView1) control, click the Item property ellipsis ... button. The ListViewItem Collection Editor dialog box appears. In the ListView Collection Editor dialog box, click Add.</li> Change the Text property of the ListViewItem to item1 .</li> Click Add, type item2 in the Text property of ListViewItem, and then click OK.</li> Drag the CheckBox control from the Device Controls tab in the Toolbox to the design view of the Form (Form1).</li> In the Properties window for the check box control, modify the Text property of the check box control to Show checkboxes.</li>  Double-click the check box control to display the code for the event handler, and then add the following code to the event handler: this.listView1.CheckBoxes = !this.listView1.CheckBoxes; </li> On the Debug menu, click Start to run the application.</li> Click to select the check box marked Show checkboxes to see the problem that is described in the &quot;Symptoms&quot; section of this article.</li> Replace the code in the CheckBox1_CheckStateChanged event with the code from the &quot;Workaround&quot; section of this article.</li> On the Debug menu, click Start to run the application.

Notice that the check boxes appear correctly.</li></ol>

Keywords: kbbug kblistview kbuidesign kblistbox kbui kbcontrol KB813561

-

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

© Microsoft Corporation. All rights reserved.