Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-20
4
Medium Priority
?
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

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

Accepted Solution

by:
jagrut_patel earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

705 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