I have in my c# application a combo box from which i select a record and then
use the split command to get then items in the combo (See Screen with the Combo box Below)

The problem i have is that ordinarily if i click on a record it show give me the last figure exchange rate
in the exchange rate box.
What happen right no is that is i just click I dont get anything selected into the exchange rate box (see below)

Now when i introduced the message box and just click ok after the messagebox comes up i get the required result
see screen below.

Definitely i dont want my application to ship out with users having to Click ok on message box
How can i solve this problem.
There must be a way to get the selection without the message box
The detailed code is shown below:
[private void glTRANSCurrencyValue_Selec
tedIndexCh
anged(obje
ct sender, EventArgs e)
{
// Setting index to 0 at form load ensure that script below is not processed during combo initial load
if (this.glTRANSCurrencyValue
.SelectedI
ndex != 0)
{
glTRANSExchrateValue.Text = "0";
System.Data.DataRowView selected_row = glTRANSCurrencyValue.Selec
tedItem as System.Data.DataRowView;
// Always use this TryParse to determin a selected value. Thencomment ou the Message Box once satisfied
bool isNumeric;
int i;
string str = glTRANSCurrencyValue.Selec
tedText.To
String();
isNumeric = int.TryParse(str, out i);
MessageBox.Show("The value of i is " + i); // Always uncomment this line to see how TryParse worked
string phrase = glTRANSCurrencyValue.Selec
tedText.To
String();
string[] words = phrase.Split(' ');
int j = 0;
foreach (var word in words) // Always put cursor on words to determine content of each field field[1] ..... field[n]. Can also Use switch to get the fields
{
j += 1;
switch (j)
{
case 3:
break;
case 5:
string var2 = $"{ word}";
glTRANSExchrateValue.Text = var2;
break;
}
}
}
}[/code]
Please Help
Olukay
you do get selected record in "selected_row" variable but later it's not used.
if your exchange rate is field in database, you can use:
glTRANSExchrateValue.Text = selected_row["name_of_fiel
other solution would be to connect your glTRANSExchrateValue textBox directly to database table, in this case you do not have to handle changing selection on glTRANSCurrencyValue.
Values will switch automatically