Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2004, 12:01 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to create a dropdown combobox in asp.net

I'd like to know how to create a dropdown combo and populate it in vb.net/asp.net

 
Old September 12th, 2004, 09:32 PM
Registered User
 
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Using the Form Designer, simply drag a ComboBox onto your form. This will by default called "ComboBox1"

In the Load event for the page, you could include:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ComboBox1.Items.Add("One")
        ComboBox1.Items.Add("Two")
        ComboBox1.Items.Add("Three")
        ComboBox1.Items.Add("Four")
        ComboBox1.Items.Add("Five")

    End Sub


This would add the five items to the drop-down box.

You could use a loop to populate the list:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        For f As Integer = 1 To 1000
            ComboBox1.Items.Add(f)
        Next

    End Sub









Similar Threads
Thread Thread Starter Forum Replies Last Post
Editable Dropdown list in ASP.NET Anypond BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 5 February 17th, 2011 09:43 PM
Regarding DropDown Lists in Asp.Net venkat_vitala ASP.NET 1.0 and 1.1 Basics 1 January 17th, 2007 09:16 AM
asp.net combobox sansircar ASP.NET 1.0 and 1.1 Professional 2 January 9th, 2006 07:02 AM
combobox dropdown style. ochanarachel General .NET 1 October 12th, 2004 12:02 AM
Issue with dropdown list and submit - ASP.NET Montenegro ASP.NET 1.0 and 1.1 Basics 0 March 24th, 2004 04:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.