2 Replies - 528 Views - Last Post: 24 March 2010 - 03:34 AM Rate Topic: -----

#1 Guest_RoseScythe*


Reputation:

Combo Box Help

Posted 20 March 2010 - 02:28 AM

Hi, I'm fairly new to C#

My Programming Class assignment has me creating a simple BMI Calculator in Microsoft VS.

I've made a working version but wanted to improve it by offering the User the option of choosing whether they want to enter their weight in either KG, Lbs, or Stone, and their height in either M, cm, or Inches.

I have two Combo Boxes setup with their respective selected items. I need to know how I'd go about changing the value of a double depending on which item is selected.

Eg. The height units selected would alter the value of the 'heightmultiplier' variable.

Any help would be greatly appreciated.

Is This A Good Question/Topic? 0

Replies To: Combo Box Help

#2 beju0506  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 78
  • Joined: 23-February 08

Re: Combo Box Help

Posted 20 March 2010 - 08:33 AM

RoseScythe,

I'm not sure which part you need help with? Getting the data from the combo boxes? Or changing the double value after the selection?

If it's just the selection that's the issue, just pull the data from the combobox using:

string myselection = this.comboBox1.SelectedItem.ToString()



Then you can use your favorite method for making decisions, if-then, switch, etc.

Does that help? Or did I misunderstand your question?

Thanks!




View PostRoseScythe, on 20 March 2010 - 01:28 AM, said:

Hi, I'm fairly new to C#

My Programming Class assignment has me creating a simple BMI Calculator in Microsoft VS.

I've made a working version but wanted to improve it by offering the User the option of choosing whether they want to enter their weight in either KG, Lbs, or Stone, and their height in either M, cm, or Inches.

I have two Combo Boxes setup with their respective selected items. I need to know how I'd go about changing the value of a double depending on which item is selected.

Eg. The height units selected would alter the value of the 'heightmultiplier' variable.

Any help would be greatly appreciated.

Was This Post Helpful? 0
  • +
  • -

#3 Guest_RoseScythe*


Reputation:

Re: Combo Box Help

Posted 24 March 2010 - 03:34 AM

View Postbeju0506, on 20 March 2010 - 07:33 AM, said:

RoseScythe,

I'm not sure which part you need help with? Getting the data from the combo boxes? Or changing the double value after the selection?

If it's just the selection that's the issue, just pull the data from the combobox using:

string myselection = this.comboBox1.SelectedItem.ToString()



Then you can use your favorite method for making decisions, if-then, switch, etc.

Does that help? Or did I misunderstand your question?

Thanks!

Cheers for the help. I figured it out. I didn't declare the Multiplier as a Class level variable so the new value was ignored outside the if statement.



View PostRoseScythe, on 20 March 2010 - 01:28 AM, said:

Hi, I'm fairly new to C#

My Programming Class assignment has me creating a simple BMI Calculator in Microsoft VS.

I've made a working version but wanted to improve it by offering the User the option of choosing whether they want to enter their weight in either KG, Lbs, or Stone, and their height in either M, cm, or Inches.

I have two Combo Boxes setup with their respective selected items. I need to know how I'd go about changing the value of a double depending on which item is selected.

Eg. The height units selected would alter the value of the 'heightmultiplier' variable.

Any help would be greatly appreciated.

Was This Post Helpful? 0

Page 1 of 1