troubleshooting Question

How can i get my comboBox selection to work properly without a message box

Avatar of Olukayode Oluwole
Olukayode OluwoleFlag for Canada asked on
C#* combobox
18 Comments1 Solution55 ViewsLast Modified:
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_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Setting index to 0 at form load ensure that script below is not processed during combo initial load
            if (this.glTRANSCurrencyValue.SelectedIndex != 0)
            {
                glTRANSExchrateValue.Text = "0";
                System.Data.DataRowView selected_row = glTRANSCurrencyValue.SelectedItem 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.SelectedText.ToString();
                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.SelectedText.ToString();
                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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 18 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros