Hello!
Sorry for the bad article title, was not sure what to name it since I couldn't figure out anything good to name it, that would be near my request.
Let me begin..
I code with Visual Studio 2010 with C# Windows Form Application.
I code everything in combobox1 and have no idea how to ingage another combobox, let me try to explain..
This is my following code
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string textfileopen = "New Folder\\testfile.txt";
try
{
StreamReader DataIn = File.OpenText(textfileopen); // Opening testfile.txt
string DataStr;
int count = 0;
double result0;
double result1;
double CalculateResult;
double combobox2Number;
string[] result; //Give each split a value of result[x]
char[] separ = new char[] { '"' }; // split words in text file
while ((DataStr = DataIn.ReadLine()) != null)
{
count++;
result = DataStr.Split(separ);
textBox1.Text = result[0]; //write out result to textbox
textBox2.Text = result[1];
textBox3.Text = result[2];
double.TryParse(result[0], NumberStyles.Any, NumberFormatInfo.CurrentInfo, out result0); //Converts string to double
double.TryParse(result[1], NumberStyles.Any, NumberFormatInfo.CurrentInfo, out result1); //Converts string to double
double.TryParse(comboBox2.SelectedItem.ToString(), NumberStyles.Any, NumberFormatInfo.CurrentInfo, out combobox2Number); //Converts selected number (string) in combobox2 to double
CalculateResult = result0 + combobox2Number * result1;
textBox4.Text = CalculateResult.ToString();
}
}
catch (InvalidCastException ex)
{
MessageBox.Show("error:" + ex.Message);
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
Now in combobox2 I got number 1 to 100 listed.
Even thought I select a new number in combobox2, it wont recalculate since I did no change in combobox1..
How can I make it re-calculate when I change in combobox2?
Is there a way to do that at all?
Please ask any questions and I'll try to answer them.