How can I make a Yes/No combobox return true/false?
- by Kasper Hansen
I am new to creating forms in Visual Studio and C#. But I made a UI that has some comboboxes where the DropDownStyle is DropDownList. The items shown is Yes and No. But I need to assign this as a boolean value to a property on some object ai and currently do this:
if (cmbExample.Text == "Yes")
{
ai.isPacketType = true;
}
else if (cmbExample.Text == "No")
{
ai.isPacketType = false;
}
I basically want to do something like this (or some other one liner):
ai.isPacketType = cmbExample.Text;
How do I link the Text Yes to the value true and No to false?