hi...

im working with vb.net
can u guys help me...

can u guys give me some sample code how to add item and display item using combo box?

please help me...

thanks...

needed a combobox to display,textbox for input and button.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ComboBox1.Items.Add(TextBox1.Text)
    End Sub

hiii...thanks Jx_Man..

this is my code :

Private Sub AddArea_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        area = New AflexiArea
        AddRate()

    End Sub

    Sub AddRate()
        area = New AflexiArea
        ReadSqlData("select (id, value) from rate")
        While myReader.Read
            ComboBox1.Items.Add(myReader.GetValue(0))

            Exit While

        End While
        CloseSqlRead()
    End Sub

but when i run..this error msg will out...
"Execute reader required an open and available connection. The connection's current state is close"

it's someting wrong with my code?

thanks..

hello..
thanks Jx_Man for ur concent helping me...

im already done now..

actually no need to put exit while

this is the real code:

Sub readrate()
        lot = New AflexiLotParking
        ReadSqlData("select value from rate")
        While myReader.Read
            ComboBox1.Items.Add("RM " & myReader.GetValue(0))

        End While
        CloseSqlRead()
    End Sub

thanks...

unable to cast COM object ADODB.Recordset to class type System.data.dataset instances of types thatrepresent COM Components cannot to be Cast to typesthat do that repersent com Components however they can be cast to interfaces as long as the underlying COM Components Supports QueryInterface calls for the IID of the Interface

HI you can add item in combobox by a simple statement like:

ComboBox_name.Items.add("Item Name",index)

ComboBox_name:- any name given to Combobox
Item Name:- name of element to be added
index :- index to which its position.

A thread is available for this Issue.
Here are both the ways to fill a combobox.
By Add() and Addrange()
By Add()

combobox1.Items.Add("Sunday")
        combobox1.Items.Add("Monday")
        combobox1.Items.Add("Tuesday")
        combobox1.Items.Add("Wednesday")
        combobox1.Items.Add("Thursday")
        combobox1.Items.Add("Friday")
        combobox1.Items.Add("Saturday")

By AddRange()

Dim days() As String = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
 ComboBox1.Items.AddRange(days)

Well, it's many ways to do this apparently... But I wondered how it's possible to copy all the items from one ComboBox (for example in form1) to another ComboBox in form 2?
I write it something like this:

ComboBox1.Items.AddRange(New String() {Form2.ComboBox1.Items})

But I get an error like

"Value of type 'System.Windows.Forms.ComboBox.ObjectCollection' cannot be converted to 'String'.

How do I copy from one to another..???

You just have to insert this:

Dim indx As Double = -1
Do Until indx = 70
    indx += 1
    ComboBox1.Items.Insert(indx, Form1.ComboBox1.Items.Item(indx))
Loop

we are updating branch master on given application, but when we populate combobox updated master not shown, can i call it's software bug or any thing else Please suggest.

combobox1.Items.Add("Sunday")
        combobox1.Items.Add("Monday")
        combobox1.Items.Add("Tuesday")
        combobox1.Items.Add("Wednesday")
        combobox1.Items.Add("Thursday")
        combobox1.Items.Add("Friday")
        combobox1.Items.Add("Saturday")
    ComboBox1.Items.Add("Sunday")
    ComboBox1.Items.Add("Monday")
    ComboBox1.Items.Add("Tuesday")
    ComboBox1.Items.Add("wednesday")
    ComboBox1.Items.Add("Thursday")
    ComboBox1.Items.Add("Friday")
    ComboBox1.Items.Add("Saturday")

    ComboBox1.SelectedItem = ComboBox1.Items(3)

Above samples full source code ..VB.Net combobox

marc

Hi everyone ..

can you please help me?

I want to add an item to a combobox from another form..
can you give me an example codes?

Thankyou in advance..

Edited 2 Years Ago by sxairyl: wrong question

But try form2.combobox.items.add("Info")
Change form2 to what ever form the combobox is on.

hello everyone,
can anybody tell me how to populate combobox by textbob by using for loop...ex if we select 3 in textbox it will show only 3 items in combobox....

This question has already been answered. Start a new discussion instead.