RadListView change column order

1 Answer 36 Views
ListView
darin
Top achievements
Rank 1
Iron
Iron
darin asked on 26 Mar 2022, 10:15 AM

I read in a previous forum post about changing the column display order by using the MOVE argument.

My question is does that really move the COLUMN or just where it is displayed?

With the standard windows listview, you can change the DisplayIndex, which only displays where that column is displayed, but the index of the column doesn't change, only the display index.

When you do a move, is it really moving the INDEX of the column

For example

Vendor #           Name               Contact Name

Move

Vendor #           Contact Name               Name

These are my columns in a DetailsView RadListView. If i move name from column 2 to 3 (or 1 to 2 is zero-based), is the DISPLAY only changing, or the actual index of the column. After the MOVE, to get the contact name of the selected column, is that index 2 or is it still the original index 3?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Mar 2022, 11:31 AM
Hello, Darin,


The columns reordering is intended to move the columns to the new index location. It is not a display-only columns reordering. The RadListView.Columns collection gets updated after the reorder operation with the new column index accordingly.

Before:

After:

    Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
        For Each col As ListViewDetailColumn In Me.RadListView1.Columns
            Console.WriteLine(col.Name)
        Next
    End Sub

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

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

darin
Top achievements
Rank 1
Iron
Iron
commented on 28 Mar 2022, 11:40 AM

Wow. Ok. So within the program i have to keep track of what column is where.

Our software allows the list to be user defined (the customer can select what columns to display). The list is the loaded from the data. Then, the user can elect to reorder the columns for their visual preference. Now, since they have reordered the columns, the program has to keep track of what SQL data is in which visual column, which is not the same order they were loaded in.

To me, that makes it more complicated within our program. When we were using the windows listview, we could always use INDEX as the order the data was originally loaded in, and DISPLAYINDEX for where the user wanted it displayed because within the program we don't care where the user wants it displayed. Now, we have to keep track of that also.

For example, if you have a list of codes with the description:

1     HOUSE

2     JIM SMITH

3     DAVID WEBER

Within the program, when the user selects a row we only care about the code. But, the user could want the name to be the first column so they can sort it by name. When they do that, then the program has to know to pull the code from the second column and not the first.

2 columns is an easy example, but imagine a list with 15+ columns and the user can move the columns in any order they want.

How do other people handle this quickly and easily, to keep basically keep the index and display index?

Dess | Tech Support Engineer, Principal
Telerik team
commented on 28 Mar 2022, 11:58 AM

Hi, Darin,

If you want to keep track of the columns order and which columns are visible, a better option is to consider using RadGridView. It provides a similar tabular data design. However, it also offers save/load layout functionality: https://docs.telerik.com/devtools/winforms/controls/gridview/save-and-load-layout/save-and-load-layout 

 

Tags
ListView
Asked by
darin
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or