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



The information in this article 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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Smart Device Application in Microsoft Visual Studio .NET 2003.
  2. Drag a ListView control from the Device Controls tab to the Toolbox.
  3. If you cannot see the Properties window, right-click the ListView control, and then click Properties.
  4. In the Properties window for the ListView (ListView1) control, set the View property to SmallIcon.
  5. In the Properties window for the ListView (ListView1) control, click the Item property ellipsis ... button. The ListViewItem Collection Editor dialog box appears.
  6. In the ListView Collection Editor dialog box, click Add.
  7. Change the Text property of the ListViewItem to item1.
  8. Click Add, type item2 in the Text property of ListViewItem, and then click OK.
  9. Drag the CheckBox control from the Device Controls tab in the Toolbox to the design view of the Form (Form1).
  10. In the Properties window for the check box control, modify the Text property of the check box control to Show checkboxes.
  11. 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;
  12. On the Debug menu, click Start to run the application.
  13. Click to select the check box marked Show checkboxes to see the problem that is described in the "Symptoms" section of this article.
  14. Replace the code in the CheckBox1_CheckStateChanged event with the code from the "Workaround" section of this article.
  15. On the Debug menu, click Start to run the application.

    Notice that the check boxes appear correctly.

Modification Type:MajorLast Reviewed:5/13/2003
Keywords:KbUIDesign kbui kbListView kbListBox kbControl kbBug KB813561 kbAudDeveloper