private void SetColumsForFolders() { if (lv_files.Columns.Count != 0) { lv_files.Columns.Clear(); } //Сортировка по умолчанию int sortedColumnIndex = 0; FileSystemComparer.SORTORDER sortOrder = FileSystemComparer.SORTORDER.ASC; //Получаем 'Сравнитель' для ListView читаем параметры сортировки FileSystemComparer currentComparer = (FileSystemComparer)lv_files.ListViewItemSorter; if (currentComparer != null) { sortedColumnIndex = currentComparer.columnIndex; sortOrder = currentComparer.sortOrder; } //Создаём столцы, с установленной иконкой ColumnHeader column = null; int currentColumnIndex = 0; foreach (KeyValuePair <string, int> item in columnsFiles) { column = new ColumnHeader(); column.Text = item.Key; column.Width = item.Value; //Иконка для столца сортированного столбца if (sortedColumnIndex == currentColumnIndex) { if (sortOrder == FileSystemComparer.SORTORDER.ASC) { column.ImageIndex = 2; } else { column.ImageIndex = 3; } } lv_files.Columns.Add(column); currentColumnIndex++; } }
private void SetColumsForFolders() { if (lv_files.Columns.Count != 0) { lv_files.Columns.Clear(); } //Default Sort int sortedColumnIndex = 0; FileSystemComparer.SORTORDER sortOrder = FileSystemComparer.SORTORDER.ASC; //We get the 'Comparison' for the ListView; we read the collation FileSystemComparer currentComparer = (FileSystemComparer)lv_files.ListViewItemSorter; if (currentComparer != null) { sortedColumnIndex = currentComparer.columnIndex; sortOrder = currentComparer.sortOrder; } //Create tables, with the icon installed ColumnHeader column = null; int currentColumnIndex = 0; foreach (KeyValuePair <string, int> item in columnsFiles) { column = new ColumnHeader(); column.Text = item.Key; column.Width = item.Value; //Icon for the column sorted column if (sortedColumnIndex == currentColumnIndex) { if (sortOrder == FileSystemComparer.SORTORDER.ASC) { column.ImageIndex = 2; } else { column.ImageIndex = 3; } } lv_files.Columns.Add(column); currentColumnIndex++; } }