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)
![Screen Showing Combox box ready for record selection]()
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)
![Screen running straight without the message box]()
Now when i introduced the message box and just click ok after the messagebox comes up i get the required result
see screen below.
![Desired result only after introducing a message box]()
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
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.