Winforms: ListBox vs. ListView

Had some discussions about Lists and controls, like Listbox and Listview, and sometimes its difficult to distinguish those.

System.Windows.Forms.ListView

  • Inherits from Control
  • Represents a Windows list view control, which displays a collection of items that can be displayed using one of four different views
  • Windows Explorer like
  • Wrapper of the standard Win32 list view

more control over appearance
4 different view styles: iconview, small icon-view, list-view, details-view (report-view)
image   image   image   image

Multiple columns are possible
image
property Multicolumn = true
 

Heavier than the listbox

Has no DataSource property, Items must be added to Items property and must be ListViewItem

No design-time databinding,  -->  maybe an advantage :-)

 Msdn Link
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.aspx

 

 

System.Windows.Forms.ListBox

  • Inherits from ListControl, common impl. for Listbox and ComboBox
  • Represents a Windows control to display a list of items

Datasource property can be used for databinding

More lightweight

Simple to use --> Use DataSource, or add your items to Items property

Msdn Link
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.aspx

 

Essence

In very simple scenarios use Listbox or ListView, but try to use the DataGridView, or even a datagrid from a third vendor.

 

There exists also a rule from SSW on this.

Do Do you always use GridView instead of ListBox?

Latest Posts

Popular Posts

 
Google Analytics Alternative