I am trying to display the result from an if statment which is based upon the option selected within a windows form combo box. I am having issues when the if statment is placed within its own class seperate to the form and is always just returning the else value.
I have tried loading the result into a public static variable and calling that across however I still get the same results.
I have also set the combobox to public. My code is as below, thanks for any help you could give me.
public partial class frmSWChange : Form
{
public frmSWChange()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
string shiftChangeValue;
label1.Text = mtxtScrapDate.Text;
xRayData xRayData1 = new xRayData();
shiftChangeValue = xRayData1.shiftChange();
label2.Text = shiftChangeValue;
}
}
class xRayData
{
#region Methods
public string shiftChange()
{
frmSWChange frmSWChange1 = new frmSWChange();
string shiftLetter;
if (frmSWChange1.cbShift.SelectedText == "Day")
{
shiftLetter = "D";
}
else if (frmSWChange1.cbShift.SelectedText == "Night")
{
shiftLetter = "N";
}
else if (frmSWChange1.cbShift.SelectedText == "Morning")
{
shiftLetter = "M";
}
else
{
shiftLetter = "ERROR";
}
return shiftLetter;
}
#endregion
}
This post has been edited by fanle: 15 September 2011 - 07:57 AM

New Topic/Question
Reply



MultiQuote










|