Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, essentially im trying to assign a value to whatever the user selects from a combobox.
For example, if A is selected then value is set to 1, If b selected then value is 2 etc.

The value would then be used to do a multiplication using input from a seperate textbox

Any help or even a push in the right direction is appreciated thanks!

What I have tried:

C#
string selected = this.cmbfacility.GetItemText(this.cmbfacility.SelectedItem);

I have used this to get the selection but just need to be able to assign it a value
Posted
Updated 18-Mar-21 1:26am
v2
Comments
Maciej Los 18-Mar-21 7:19am    
How do you bind data to that combobox?
Ishimora1 18-Mar-21 7:23am    
I added data to it via the properties tab -> Data -> Items then typed in the selections individually

1 solution

Why to force doors wide open?

Please, check this: Bind ComboBox or ListBox Control to Data - Windows Forms .NET Framework | Microsoft Docs[^]

For further details, please see:
DisplayMember[^] - defines what values are dsiplayed
ValueMember[^] - defines what values are returned ;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900