vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Monday, May 16, 2011

ADD AND REMOVE ITEMS FROM THE COMBOBOX IN VB.NET


Hi...

INTRODUCTION:
In this article i am going to describe about How to add and remove items in combo box ..

i think it may helpful those who starter in vb.net..

DESCRIPTION:

First add a combobox in your form...

To add a particular column from the database to combo box..
For examble here i add the all the phone number from database to combobox...

str = "select Number from phone"
        sqlcmd = New SqlCommand(str, sqlcon)
        dr = sqlcmd.ExecuteReader()
        ComboBox1.Items.Clear()
        If dr.HasRows Then
            While dr.Read
                ComboBox1.Items.Add(dr(0).ToString)
            End While
        End If

By using this code its all the number into combo box...

Suppose if you want to remove all the items in combobox...

        ComboBox1.Items.Clear()

To remove 3rd items in the combobox

        ComboBox1.Items.RemoveAt(3)

To remove the selected items from the combo box

        ComboBox1.Items.Remove(ComboBox1.SelectedItem)
or
        ComboBox1.Text = ""

PLZ POST YOUR VALUABLE COMMENTS .............

0 comments:

Post a Comment