Solved

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

Posted on 2009-07-15
2
523 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problems running a .Net executable from Task Scheduler, program uses Process.Start 7 26
DataGridView Events ? 3 37
ASP.NET 5 Templates 2 65
Error in JQuery 5 35
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

16 Experts available now in Live!

Get 1:1 Help Now