Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8012913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:28:56+00:00 2026-06-04T19:28:56+00:00

I have a listview like this and in FormLoad event I should do some

  • 0

I have a listview like this and in FormLoad event I should do some initializations for it such as this: ( I need these ) .

    listView.Scrollable = true;
    listView.HideSelection = false;
    listView.FullRowSelect = true;
    listView.View = View.Details;
    listView.HeaderStyle = ColumnHeaderStyle.None;
    ColumnHeader header = new ColumnHeader();
    header.Text = "MyHdr";
    header.Name = "MyCol";
    header.Width = listView.ClientSize.Width;
    listView.Columns.Add(header);

and the way I am adding items to it is pretty simple like this:

listView.Items.Add("hello");
listView.Items.Add("How are you");
//... etc

But I want them to be added and sorted alphabetically but when I add a new item to it and call Sort method, it doesn’t do anything.
Why?! 🙁

EDIT: This is the whole section that at its last line I am calling Sort()
The goal is to have two list views, and a Move Button, when Move button is clicked the selected items from one listview should get moved to the other listview.
(Both listviews don’t need to be sorted. Just the AvailLV listview should be sorted )

private void MoveBtn_Click(object sender, EventArgs e)
{
    ListView source=null;
    ListView target= null;

    if(AvailableLV.SelectedItems.Count>0)
    {
        source = AvailableLV;
        target = SelectedLV;
    }

    if(SelectedLV.SelectedItems.Count>0)
    {
        source = SelectedLV;
        target = AvailableLV;
    }

    if (source != null && target != null)
    {
        HaulItems(source, target);
    }
}

private void HaulItems(ListView source , ListView target)
{
    foreach(ListViewItem item in source.Items)
    {
        if(item.Selected)
        {
            source.Items.Remove(item);
            target.Items.Add(item);
        }
    }
    AvailableLV.Sort();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:28:58+00:00Added an answer on June 4, 2026 at 7:28 pm

    Where are you setting your ListView.Sorting Property

    From above link:

    The Sorting property allows you to specify whether or not items are sorted in the ListView control. By default, no sorting is performed. When the Sorting property is set to Ascending or Descending, the items in the ListView are sorted automatically in ascending alphabetical order (when the property is set to Ascending) or descending alphabetical order (when the property is set to Descending). You can use this property to automatically sort items that are displayed in your ListView control to make it easier for users to find items when a large number of items are available.


    Looking at your edit, I think all you need to do is set the ListView.Sorting Property on AvailableLV and it will automatically sort your items as they are added. or instead of calling.

    AvailableLV.Sort(); 
    

    use

    AvailableLV.Sorting = SortOrder.Ascending;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a listView with some formulas like this: ((A * 2
I have a ListView in my aspx file like this: <asp:ListView ID=ListView1 runat=server></asp:ListView> and
I have a ListView setup in details mode that looks like this: When the
I have a ListView control on my form set up like this in details
I have a setup, something confusing like this: <ListView> <ItemTemplate> <div id=Content> <asp: TextBox
I have a collection of objects I bind to a Listview like this: if
I have a item in a listView control like this <asp:Label ID=Label2 runat=server Text='<%#Eval(Open)
I have three ListView widgets in the same LinearLayout . Something like this (I'm
I have a listview like this : <telerik:RadListView ID=rlv_available_sys runat=server ItemPlaceholderID=sys_holder DataKeyNames=process_id OnItemDataBound=rlv_available_sys_ItemDataBound> <ItemTemplate>
I have a customized ListView like this: List<Journal_Database> values = localDatabase.getAllJournalNames(); ListView journalNames =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.