Previous | Index | Next 

[INFO] Minor differences between VB6 and VB.NET ListView controls

VB Migration Partner’s support library hides most of the differences between the VB6 and the .NET versions of the ListView control, but not all of them. In most cases the remaining differences should have no impact on migrated programs. Here’s their complete list:

  1. When you assign an icon to a column header of the VB6 ListView control, the icon’s index or name is searched inside the ColumnHeaderIcons collection. The .NET ListView control doesn’t exposes such a collection and column headers’ icons are taken from the SmallIcons collection. By default, the VB6ListView control ignores icon indexes specified in the ColumnHeaders.Add method or assigned to the ColumnHeader.Icon property, because the resulting icon would be incorrect.

    You can display column headers’ icons as follows: (1) in the original VB6 application, ensure that the ColumnHeaderIcons property points to the same ImageList control referenced by the SmallIcons property; (2) if necessary, update all the icon indexes mentioned in the ColumnHeaders.Add methods or ColumnHeader.Icon properties; (3) enable column headers’ icons by setting the new ColumnHeaderIconsEnabled property to True. This property is exposed by the VB6ListView control and can be set by means of a WriteProperty pragma:
            '## ListView1.WriteProperty  ColumnHeaderIconsEnabled, True
  2. The FlatScrollBar property isn’t supported and is marked as obsolete. Reading this property always returns False; assigning it the True value throws an exception (if VB6Config.ThrowOnUnsupportedMember is True).
  3. The TextBackground property isn’t supported and is marked as obsolete. Reading this property always returns the value 0-Opaque; assigning it the 1-Transparent value throws an exception (if VB6Config.ThrowOnUnsupportedMember is True).
  4. The Ghosted property of the ListItem object isn’t supported and is marked as obsolete. Reading this property always returns False; assigning it the True value throws an exception (if VB6Config.ThrowOnUnsupportedMember is True).
  5. The ToolTipText property of the ListSubItem object isn’t supported and is marked as obsolete. Reading this property always returns an empty string; assigning it a value other than an empty string throws an exception (if VB6Config.ThrowOnUnsupportedMember is True).
  6. The ReportIcon property of the ListSubItem object isn’t supported and is marked as obsolete. Reading this property always returns the Icon property of the parent ListItem object; assigning it a different non-Nothing value throws an exception (if VB6Config.ThrowOnUnsupportedMember is True).
  7. When the View property is set to LargeIcons or SmallIcons, the VB6 control allows you to arrange items with the mouse; conversely, the .NET ListView never allows you to move items.
  8. When you click on the blank area in the .NET ListView control, the currently highlighted item is unselected; when you perform the same operation on the VB6 ListView control, the currently selected item stays selected. (In VB6 you can unselect the currently selected item via code, though.) This difference in behavior is important because your VB6 code might assume that the ListView.SelectedItem always returns a non-Nothing value, whereas this isn’t true in the converted VB.NET code. You should revise your code to ensure that you always test this property before using it.
  9. The ListView’s ToolTipText property is converted correctly, however by default the ShowItemToolTips property of the .NET control is set to True, which prevents the control’s tooltip to appear in favor of the tooltip of individual items. You can force the display of the control’s tooltip by setting the ShowItemToolTips property to False.
  10. If the input focus is currently on the .NET ListView control and you then activate another application and finally go back to the .NET application, the control raises several LostFocus and GotFocus events. The VB6 ListView control doesn’t raise all these extra events.
  11. The VB6 ListView control raises a Click event also if you click on the control’s blank area, whereas the .NET ListView control raises the Click event only if you click on an item.
  12. When you click on an item, the VB6 ListView control raises the following sequence of events: MouseDown, ItemClick, MouseUp, Click. In the .NET control the event sequence is: MouseDown, Click, ItemClick, MouseUp.
  13. When you edit an item, the .NET ListView control raises the following events: BeforeLabelEdit, LostFocus, AfterLabelEdit, GotFocus. The VB6 ListView control raises only the BeforeLabelEdit and AfterLabelEdit events.
  14. When you move the input focus to a VB6 ListView control using the mouse, the event sequence is: MouseDown, GotFocus, MouseUp. The same operation causes the .NET control to raise the events in this order: GotFocus, MouseDown, MouseUp.
  15. When you click on the checkbox associated with an item, the VB6 ListView control raises the following events: MouseDown, ItemCheck, MouseUp, Click. In the same circumstances the .NET control fires these events: MouseDown, Click, ItemClick, MouseUp, ItemCheck.
  16. The ItemClick event is fired when the ListView element is clicked with the mouse; for this reason, this event doesn’t fire if the end user moves to another item using the arrow keys.

 

Previous | Index | Next