Solved

C# -- ListBox.Items.Insert -- SORTING ?

Posted on 2009-07-15
2
521 Views
Last Modified: 2013-12-17
I dropped a list box onto the page, added the below EVENT, ran the app, clicked anywhere on the APP multiple times, and my listbox got populated.  How can I change the below so NEWEST values appear as the last entry instead of the first entry ?
----------------------------------------------------------------------------------------------------
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            string locationText = String.Format("{0}, {1}", e.X, e.Y);
            listBox1.Items.Insert(0, locationText);
        }
----------------------------------------------------------------------------------------------------
0
Comment
Question by:finance_teacher
2 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 500 total points
ID: 24861097

 private void Form1_MouseClick(object sender, MouseEventArgs e)

        {

            string locationText = String.Format("{0}, {1}", e.X, e.Y);

            listBox1.Items.Add(locationText);

        }

Open in new window

0
 
LVL 22

Expert Comment

by:p_davis
ID: 24861420
or if you are set on the insert

private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            string locationText = String.Format("{0}, {1}", e.X, e.Y);
            listBox1.Items.Insert(listBox1.Items.Count-1, locationText);
        }
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now