Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

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

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
finance_teacher
Asked:
finance_teacher
1 Solution
 
jinalCommented:

 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
 
p_davisCommented:
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

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now