This is a migrated thread and some comments may be shown as answers.

Removing the sort arrow from headers

7 Answers 559 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ohad
Top achievements
Rank 1
Ohad asked on 24 May 2020, 02:54 AM

I'm trying to remove the sort arrow from column headers in the RadListView control.

I attached an image for example.

Thank you.

7 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 May 2020, 05:12 AM

Hello, Ohad,

The RadListView.EnableColumnSort property controls whether the sort arrows in the header cells will be displayed. If you set it to false, the arrows won't be shown in the headers at all.

Additional information about sorting in RadListView is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/listview/features/sorting 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ohad
Top achievements
Rank 1
answered on 25 May 2020, 10:17 AM

Thanks for the reply.

I've already set the EnableColumnSort property to false, and it's still showing.

0
Ohad
Top achievements
Rank 1
answered on 25 May 2020, 10:28 AM

Also the RadListView.EnableColumnSort property is already initialized with false, and when I add a RadListView control to the form the sort arrows are showing, so this property doesn't change the arrows visibility.

BTW - I'm using the Material theme.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 May 2020, 10:33 AM
Hello, Ohad,  

I suppose that you set the EnableColumnSort property to false but leave the EnableSorting property true. Thus, if you add a SortDescriptor programmatically, the column header will indicate the sort order and show the arrow.

If this is your case, you can still eliminate the arrow by handling the CellFormatting event as it is demonstrated in the following code snippet:

        private void RadListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
        {
            DetailListViewHeaderCellElement headerCell = e.CellElement as DetailListViewHeaderCellElement;
            if (headerCell != null)
            {
                ArrowPrimitive arrow = headerCell.FindDescendant<ArrowPrimitive>();
                if (arrow!=null)
                {
                    arrow.Visibility = ElementVisibility.Collapsed;
                }
            }
        }

        private void RadForm1_Load(object sender, EventArgs e)
        { 
            this.productsTableAdapter.Fill(this.nwindDataSet.Products);

            this.radListView1.EnableSorting = true;
            this.radListView1.EnableColumnSort = false;
            SortDescriptor sort = new SortDescriptor("ProductName", ListSortDirection.Descending);
            radListView1.SortDescriptors.Add(sort);
        }

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ohad
Top achievements
Rank 1
answered on 25 May 2020, 10:38 AM

UPDATE: I've changed to other theme and the RadListView.EnableColumnSort = false  now hides the arrows, I changed again to Material theme and the arrows are still showing, so apparently this is a bug on the Material theme.

I need to get the arrow's control and change it's visibility somehow.

0
Ohad
Top achievements
Rank 1
answered on 25 May 2020, 10:46 AM

Thanks, your code in the CellFormatting worked.

It's still looks like a bug on the Material theme, this was my code:

this.radListView1.EnableSorting = false;

this.radListView1.EnableColumnSort = false;

and no SortDescriptor, and still I had the arrows visible.

But it works now with your code, so many thanks!

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 May 2020, 07:47 AM
Hello, Ohad,  

I am glad that the suggested solution for the CellFormatting event is suitable for your case. Setting only the EnableColumnSort property to false will disable the sorting functionality with clicking the header cell. However, if you add a SortDescriptor via code , in this case the arrow will be shown no matter what theme is applied.

That is why the code snippet for hiding the arrow in the CellFormatting event is the appropriate way to ensure that the arrow won't be shown. 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ListView
Asked by
Ohad
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ohad
Top achievements
Rank 1
Share this question
or