RadioDld.Main.ListDownloads_ColumnReordered C# (CSharp) Method

ListDownloads_ColumnReordered() private method

private ListDownloads_ColumnReordered ( object sender, System.Windows.Forms.ColumnReorderedEventArgs e ) : void
sender object
e System.Windows.Forms.ColumnReorderedEventArgs
return void
        private void ListDownloads_ColumnReordered(object sender, ColumnReorderedEventArgs e)
        {
            string[] oldOrder = new string[this.ListDownloads.Columns.Count];

            // Fetch the pre-reorder column order
            foreach (ColumnHeader col in this.ListDownloads.Columns)
            {
                oldOrder[col.DisplayIndex] = ((int)this.downloadColOrder[col.Index]).ToString(CultureInfo.InvariantCulture);
            }

            List<string> newOrder = new List<string>(oldOrder);
            string moveCol = newOrder[e.OldDisplayIndex];

            // Re-order the data to match the new column order
            newOrder.RemoveAt(e.OldDisplayIndex);
            newOrder.Insert(e.NewDisplayIndex, moveCol);

            // Save the new column order to the preference
            Settings.DownloadCols = string.Join(",", newOrder.ToArray());

            if (e.OldDisplayIndex == 0 || e.NewDisplayIndex == 0)
            {
                // The reorder involves column 0 which contains the icons, so re-initialise the list
                e.Cancel = true;
                this.InitDownloadList();
            }
        }
Main