Solved

How to get an element in the ListBox and put it in textbox

Posted on 2011-09-20
4
260 Views
Last Modified: 2013-12-17
Hi,
I have a little problem I want to get the code for the selected item in the listbox, but only the code and add it to my textbox. my code below show what I want
Any idea?
Apparently it's easy to get all the SelectedItem but I want only part I have already put in an ArrayList m_currentLookupCodeChoice

thank you in advance
private void lbxListeEvent_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (lbxListeEvent.Items != null)

                tbCode.Text += m_currentLookupCodeChoice+ ".";
            
        }

        /// <summary>
        /// Getting ParseBet response asynchrounsly 
        /// </summary>
        /// <param name="asynchronousResult"></param>
        public void ParseBetResp_Callback(IAsyncResult asynchronousResult)
        {

            string myResponse = null;
            try
            {
                myResponse = isbb.RetailServices.HttpGetResponse(asynchronousResult);
                Debug.WriteLine("ParseBet Response : " + myResponse);
            }
            catch (WebException)
            {
            }
            if (myResponse != null)
            {
                Invoke(new MethodInvoker(delegate
                 {
                     DisplayResponse(myResponse);
                 }
                    ));
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="asynchronousResult"></param>
        private void DisplayResponse(string myResponse)
        {
            MyObject myObject = null;

            myObject = isbb.RetailServices.ReadToObjectMyObject(myResponse);
            if (myObject != null)
            {
                if (myObject.mySelection == null)
                {
                    tbBetDescription.Text = myObject.currentSelectionDescription;
                    lbxListeEvent.Items.Clear();
                  
                    foreach (var item in myObject.choices)
                    {
                        lbxListeEvent.Items.Add(item.Code + "  :  " + item.description);
                        m_currentCodeChoice.Add(item.Code);
                       
                    }
                     
                   
                }

                else if (myObject.choices.Count == 0)
                {
                    tbBetDescription.Clear();
                    lbxListeEvent.Items.Clear();

                    lbxCapture.Items.Add(myObject.mySelection.eventLookupCode + ". " + myObject.mySelection.description);
                    lbxCapture.Items.Add(isbb.NetworkServices.ConvertDate(myObject.mySelection.eventStartDate));
                    lbxCapture.Items.Add(myObject.mySelection.marketDescription + "   " + myObject.mySelection.periodDescription);
                    lbxCapture.Items.Add(myObject.mySelection.outcomeDescription + "   " + myObject.mySelection.price);
                    lbxCapture.Items.Add("");
                    tbCode.Clear();
                    m_reponse.Add(myObject.mySelection.lookupCode);

                    btnSubmit.Enabled = true;
                    btnClearCapture.Enabled = true;
                    m_nbreOfBet = m_reponse.Count.ToString();

                    lblNbreOfElt.Text = m_nbreOfBet;
                    m_currentCodeChoice.Clear();

                    
                }
            }

        }

Open in new window

0
Comment
Question by:abgconsulting
  • 2
  • 2
4 Comments
 

Author Comment

by:abgconsulting
ID: 36569556
Do you have any idea ????
0
 
LVL 8

Accepted Solution

by:
jagrut_patel earned 500 total points
ID: 36571848
Not sure what are asking for!

I didn't get what you mean by "but I want only part I have already put in an ArrayList m_currentLookupCodeChoice". Your code does not show where "m_currentLookupCodeChoice" is populated.
In your code there is a line "m_currentCodeChoice.Add(item.Code);". A different variable name! Assuming it is a typo I think you need this,


string code;
foreach (string selectedItem in lbxListeEvent.SelectedItems)
{
    code = selectedItem.Substring(0, selectedItem.IndexOf(':') + 1).Trim();
    foreach (string lookupCode in m_currentLookupCodeChoice)
    {
        if(lookupCode.Equals(code, StringComparison.CurrentCultureIgnoreCase))
            tbCode.Text += code + ".";
    }
}

Open in new window


HTH!
0
 

Author Comment

by:abgconsulting
ID: 36573519
thanks Jagrut !!! u put me on the way to solve my problem !!!


Moussa
0
 
LVL 8

Expert Comment

by:jagrut_patel
ID: 36573747
Please don't forget to rate the solution.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question