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
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
Our thoughts here at Progress are with those affected by the outbreak.
Thanks for the reply.
I've already set the EnableColumnSort property to false, and it's still showing.
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.
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
Our thoughts here at Progress are with those affected by the outbreak.
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.
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!
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
Our thoughts here at Progress are with those affected by the outbreak.