asp.net.ph

ListBox Constructor

System.Web.UI.WebControls Namespace   ListBox Class


Initializes a new instance of the ListBox class.

[ VB ]
Public Sub New ( )

[ C# ]
public ListBox ( );

[ C++ ]
public: ListBox ( );

[ JScript ]
public function ListBox ( );

Remarks

When using this constructor to instantiate a new instance of the ListBox control, the ListItem and ListItemCollection classes are also used. The ListItem control stores the item content whereas the ListItemCollection allows it to be added to the ListBox control.

Example

The following example demonstrates how to initialize a new instance of the ListBox class.

void Page_Load ( Object src, EventArgs e ) {
   if ( !IsPostBack ) {
      ArrayList myListItems = new ArrayList ( );
      myListItems.Add ( "Item 1" );
      myListItems.Add ( "Item 2" );
      myListItems.Add ( "Item 3" );
      myListItems.Add ( "Item 4" );
      myListItems.Add ( "Item 5" );

      ListBox myList = new ListBox ( );
      Page.Controls.Add ( myList )
      myList.DataSource = myListItems;
      myList.DataBind ( );
   }
}
  C# VB

See Also

ListBox Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph