Text of a ListView item is changed when the Text property of the first subitem is set (822489)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SYMPTOMS

You have a ListView control in Details view and you add columns to the control. You add an item to the control, and then you set the Text property of the item. When you add a subitem to this item, and you then set the Text property of the first subitem in the ListViewSubItem Collection Editor dialog box, the text of the item in the first column of the ListView control is changed to the text of the subitem.

Note The first column in the ListView control displays the Text property of the items. All the other columns display the Text property of the subitems of the main item.

WORKAROUND

To work around the problem, add a subitem to the list item, and then set the Text property. To do this, follow these steps:
  1. Perform steps 1-10 in the "Steps to Reproduce the Behavior" section.
  2. In the ListViewSubItem Collection Editor dialog box, click Add.
  3. Set the Text property to SubItem1, and then click OK.
  4. In the ListViewItem Collection Editor dialog box, click OK.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Microsoft Visual Studio .NET.
  2. Create a new Windows Application project by using Visual Basic .NET or Visual C# .NET. By default, Form1 is created.
  3. Add a ListView control to Form1.
  4. Right-click ListView1, and then click Properties.
  5. In the Properties dialog box, set the View property to Details.
  6. Select the Columns property, and then click the ellipsis button (...).
  7. In the ColumnHeader Collection Editor dialog box, click Add three times, and then click OK.
  8. Select the Items property, and then click the ellipsis button (...).
  9. In the ListViewItem Collection Editor dialog box, click Add.
  10. Set the Text property of the ListView item to Item1.
  11. Select the SubItems property, and then click the ellipsis button (...).
  12. In the ListViewSubItem Collection Editor dialog box, set the Text property to Subitem1, and then click OK.
  13. In the ListViewItem Collection Editor dialog box, click OK.
In ListView1, the text in the first column is "Subitem1". You expect the text in the first column to be "Item1" and you expect the text in the second column to be "Subitem1".

REFERENCES

For more information, visit the following MSDN Web site:

Modification Type:MajorLast Reviewed:1/26/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbProperties kbWindowsForms kbDesigner kbListView kbCtrl kbControl kbprb KB822489 kbAudDeveloper