private void lvApp_ColumnReordered(object sender, ColumnReorderedEventArgs e) { // if locked listview if (ListViewUtil.IsLockedUpdate(lvApp)) { return; } List <int> IndexOrderList = new List <int>(); if (e.OldDisplayIndex < e.NewDisplayIndex) { for (int i = 0; i < e.OldDisplayIndex; i++) { IndexOrderList.Add(ListViewUtil.GetIndexByDisplayIndex(lvApp, i)); } for (int i = e.OldDisplayIndex + 1; i <= e.NewDisplayIndex; i++) { IndexOrderList.Add(ListViewUtil.GetIndexByDisplayIndex(lvApp, i)); } IndexOrderList.Add(e.Header.Index); for (int i = e.NewDisplayIndex + 1; i < lvApp.Columns.Count; i++) { IndexOrderList.Add(ListViewUtil.GetIndexByDisplayIndex(lvApp, i)); } } else if (e.OldDisplayIndex > e.NewDisplayIndex) { for (int i = 0; i < e.NewDisplayIndex; i++) { IndexOrderList.Add(ListViewUtil.GetIndexByDisplayIndex(lvApp, i)); } IndexOrderList.Add(e.Header.Index); for (int i = e.NewDisplayIndex; i < e.OldDisplayIndex; i++) { IndexOrderList.Add(ListViewUtil.GetIndexByDisplayIndex(lvApp, i)); } for (int i = e.OldDisplayIndex + 1; i < lvApp.Columns.Count; i++) { IndexOrderList.Add(ListViewUtil.GetIndexByDisplayIndex(lvApp, i)); } } for (int i = 0; i < IndexOrderList.Count; i++) { iniSettings.Write( lvApp.Columns[IndexOrderList[i]].Text.Replace(" ", "").Replace("∧", "").Replace("∨", ""), i.ToString(), "ColumnHeaderDisplayIndex"); } }
private void lvApp_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e) { // if locked listview if (ListViewUtil.IsLockedUpdate(lvApp)) { return; } iniSettings.Write(lvApp.Columns[e.ColumnIndex].Text.Replace(" ", "").Replace("∧", "").Replace("∨", ""), lvApp.Columns[e.ColumnIndex].Width, "ColumnHeaderWidth"); }
private void lvApp_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e) { // if locked listview if (ListViewUtil.IsLockedUpdate(lvApp)) { return; } // min width if (e.NewWidth < ColumnMinWidth) { e.Cancel = true; e.NewWidth = lvApp.Columns[e.ColumnIndex].Width; } }