Problem w/ComboBox

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

Me.cbxLocation.Items.AddRange(New Object() {"Item0", "Item1", "Item2", "Item3"})
Me.cbxLocation.DropDownWidth = 114
Me.cbxLocation.Location = New System.Drawing.Point(72, 16)
Me.cbxLocation.Name = "cbxLocation"
Me.cbxLocation.Size = New System.Drawing.Size(112, 21)
Me.cbxLocation.TabIndex = 0

'Should return "Item0"
cbxLocation.GetItemText(0) <=returns 0

'Should return "Item1"
cbxLocation.GetItemText(1) <=returns 1

'Should return "Item2"
cbxLocation.GetItemText(2) <=returns 2

'Should return "Item3"
cbxLocation.GetItemText(3) <=returns 3

GetItemText seems to be returning the INDEX of the requested item rather than the item TEXT. What in the world would cause such a thing?

Thanks a lot!
 
Me.cbxLocation.Items.AddRange(New Object() {"Item0", "Item1", "Item2", "Item3"})
Me.cbxLocation.DropDownWidth = 114
Me.cbxLocation.Location = New System.Drawing.Point(72, 16)
Me.cbxLocation.Name = "cbxLocation"
Me.cbxLocation.Size = New System.Drawing.Size(112, 21)
Me.cbxLocation.TabIndex = 0

'Should return "Item0"
cbxLocation.GetItemText(0) <=returns 0

'Should return "Item1"
cbxLocation.GetItemText(1) <=returns 1

'Should return "Item2"
cbxLocation.GetItemText(2) <=returns 2

'Should return "Item3"
cbxLocation.GetItemText(3) <=returns 3

GetItemText seems to be returning the INDEX of the requested item rather than the item TEXT. What in the world would cause such a thing?

Thanks a lot!
 
Don,

Use this instead !

MessageBox.Show(cbxLocation.Items(1).ToString())

Regards - OHM#


(e-mail address removed)
Me.cbxLocation.Items.AddRange(New Object() {"Item0", "Item1", "Item2", "Item3"})
Me.cbxLocation.DropDownWidth = 114
Me.cbxLocation.Location = New System.Drawing.Point(72, 16)
Me.cbxLocation.Name = "cbxLocation"
Me.cbxLocation.Size = New System.Drawing.Size(112, 21)
Me.cbxLocation.TabIndex = 0

'Should return "Item0"
cbxLocation.GetItemText(0) <=returns 0

'Should return "Item1"
cbxLocation.GetItemText(1) <=returns 1

'Should return "Item2"
cbxLocation.GetItemText(2) <=returns 2

'Should return "Item3"
cbxLocation.GetItemText(3) <=returns 3

GetItemText seems to be returning the INDEX of the requested item rather than the item TEXT. What in the world would cause such a thing?

Thanks a lot!
 
Thanks for the assist. That did work. I'm still kind of curious why MS says that getItemText will return the text of the specified item (although I don't truly expect anyone here to know the answer).

From the help's ListItem.GetItemText Method entry:
Returns the text representation of the specified item.

--

Don
Don,

Use this instead !

MessageBox.Show(cbxLocation.Items(1).ToString())

Regards - OHM#


(e-mail address removed)
Me.cbxLocation.Items.AddRange(New Object() {"Item0", "Item1", "Item2", "Item3"})
Me.cbxLocation.DropDownWidth = 114
Me.cbxLocation.Location = New System.Drawing.Point(72, 16)
Me.cbxLocation.Name = "cbxLocation"
Me.cbxLocation.Size = New System.Drawing.Size(112, 21)
Me.cbxLocation.TabIndex = 0

'Should return "Item0"
cbxLocation.GetItemText(0) <=returns 0

'Should return "Item1"
cbxLocation.GetItemText(1) <=returns 1

'Should return "Item2"
cbxLocation.GetItemText(2) <=returns 2

'Should return "Item3"
cbxLocation.GetItemText(3) <=returns 3

GetItemText seems to be returning the INDEX of the requested item rather than the item TEXT. What in the world would cause such a thing?

Thanks a lot!
 
Back
Top