We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

How to get selected item from combo box to a variable

IT79637
IT79637 asked
on
Medium Priority
25,059 Views
Last Modified: 2013-11-23
Hi Experts.

How do I get the selected value out of a combo box and into a variable?  I puzzled, because I don't know what the index is.
var := ComboBox1.???;

Thanks much.
Comment
Watch Question

Oracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
var x: integer;
  t: string;
begin
  x := Combobox1.ItemIndex;
  t := Combobox1.Text;
 
  // or :
  if Combobox1.ItemIndex > -1 then
    t := Combobox1.Items[Combobox1.ItemIndex];
end;

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
MerijnBSr. Software Engineer
CERTIFIED EXPERT
Commented:
I don't know if you want the index of the value, so here's both:
var index: integer;
    value: string;
begin
 index := ComboBox1.ItemIndex;
 value := ComboBox1.Items[ComboBox1.ItemIndex];
 // you might want to check if the index is valid (it can be -1 if nothing is selected)
end;

Open in new window

MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
lol, too late :)
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009

Commented:
i didn't type that much comments ...

Author

Commented:
Thanks for your response.  I upped the points to 400 points so points could be awarded to both Geert_Gruwez and MerijnB. Their responses were correct and the fact they responded within a minute of each other.

Thanks again.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.