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?

5 comments:

Unknown said...

how access to rowindex in juanus(gridvie)

Peter Gfader said...

Mohammad, Can you be a bit more specific?

I guess you are using the Janus GridEx control.

GridEX1.CurrentRow.RowIndex should help you a bit further

check
http://www.janusys.com/controls/

Anonymous said...

thanks for pointing that out. saves me time developing

Rahul Rathaur said...

hello dude.
i want to set item space in listBox items

Peter Gfader said...

@Rahul Rathaur

Please ask on Stackoverflow

Post a Comment

Latest Posts

Popular Posts