combo box

code in combo box

Page 1 of 1

6 Replies - 3380 Views - Last Post: 03 January 2009 - 10:59 PM Rate Topic: -----

#1 jencalma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 89
  • Joined: 13-July 07

combo box

Posted 03 January 2009 - 09:09 PM

how can you add an item in a combo box without using the property window,, i tried using the items.add but there's an error and I forgot what it is..
here's the code i'm trying to do:

dim shift as integer
shift = cboShift.selectedindex

select shift
case 0
cboLocation.items.add="a"
cboLocation.items.add="b"
cboLocation.items.add="c"
case 1
cboLocation.items.add="A"
cboLocation.items.add="B"
cboLocation.items.add="C"
end select

is it correct???? :) thankyou for the help in advance

Is This A Good Question/Topic? 0
  • +

Replies To: combo box

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: combo box

Posted 03 January 2009 - 09:14 PM

View Postjencalma, on 3 Jan, 2009 - 08:09 PM, said:

dim shift as integer
shift = cboShift.selectedindex

select shift
case 0
   cboLocation.items.add="a"
   cboLocation.items.add="b"
   cboLocation.items.add="c"
case 1
   cboLocation.items.add="A"
   cboLocation.items.add="B"
   cboLocation.items.add="C"
end select


Please post your code examples using tags: :code:

//'cboLocation.items.add="a"
   cboLocation.Items.Add("a")



See ComboBox.Items Property

This post has been edited by n8wxs: 03 January 2009 - 09:17 PM

Was This Post Helpful? 0
  • +
  • -

#3 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: combo box

Posted 03 January 2009 - 09:16 PM

You should use

cboLocation.Items.Add("a")



instead of

cboLocation.Items.Add="a"



And it should be Select Case instead of just Select.
Was This Post Helpful? 0
  • +
  • -

#4 jencalma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 89
  • Joined: 13-July 07

Re: combo box

Posted 03 January 2009 - 10:32 PM

Dim intCat As Integer
intCat = cboCat.SelectedIndex

Select Case intCat
Case 0
cboLoc.Items.Add("Angeles")
cboLoc.Items.Add("Mabalacat")
cboLoc.Items.Add("San Fernando")
Case 1
cboLoc.Items.Add("USA")
cboLoc.Items.Add("Canada")
cboLoc.Items.Add("London")
Case 2
cboLoc.Items.Add("Baguio")
cboLoc.Items.Add("Manila")
cboLoc.Items.Add("Palawan")
End Select


i have a problem with these,, i follow all what you've said but every time i click the cboCat,, my items in cboLoc are just adding up.. what will i do so my items in cboLoc are not adding everytime i click cboCat,, :D
Was This Post Helpful? 0
  • +
  • -

#5 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: combo box

Posted 03 January 2009 - 10:36 PM

You should add this at the beginning of every case selection if you want the CheckBox to be cleared and only then filled with other items:

		cboLoc.Items.Clear()


Was This Post Helpful? 0
  • +
  • -

#6 jencalma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 89
  • Joined: 13-July 07

Re: combo box

Posted 03 January 2009 - 10:56 PM

View PostCore, on 3 Jan, 2009 - 09:36 PM, said:

You should add this at the beginning of every case selection if you want the CheckBox to be cleared and only then filled with other items:

		cboLoc.Items.Clear()




txtCat.Text = cboCat.Text
txtLoc.Text = cboLoc.Text

i try this but in the txtLoc the item in cboLoc does not appear,, but in txtCat it appears.. hows that??? ehe tnx :D
Was This Post Helpful? 0
  • +
  • -

#7 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: combo box

Posted 03 January 2009 - 10:59 PM

Please be more specific about the problem. What are you trying to do and what code are you trying to use. Please, post the code between code tags: :code:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1