1.11M Members

add items to combobox

 
0
 

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...

 
0
 

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
 
0
 

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..

 
0
 

open connection is required to connect.

 
0
 

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...

Question Answered as of 6 Years Ago by Jx_Man
 
0
 

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

 
0
 

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.

 
0
 

hi frnds..
i have same query but i want to use Add Range Method to fill me combo box..
please guide

 
0
 

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)
 
0
 

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..???

 
0
 

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
 
0
 

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.

 
0
 

Hi, I vb.net Where do I get the ComboBox, and similar things?

 
0
 
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")
 
0
 
    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

 
0
 

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..

 
0
 

Sxairyl,
Maybe we should create a new post. This one looks very old.

 
0
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article