TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shikha p
NA
1
10.4k
how to sort the values of listbox
May 3 2011 8:43 PM
i want to sort the values of listbox, both in ascending and descending order
but in the following code there is some error... pls help
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
ArrayList list1 = new ArrayList();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox1.Text);
list1.add(textBox1.Text);
textBox1.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
list1.Sort();
Object[] arr = list1.ToArray();
listBox2.Items.Clear();
listBox2.Items.AddRange(arr);
list1.Reverse();
Object[] arr1 = list1.ToArray();
listBox3.Items.Clear();
listBox3.Items.AddRange(arr1);
}
Reply
Answers (
2
)
How to Check if an item Exist in a ListBox
How to get items in order by min to max and move to temp list c#?