private void ChooseCols_Load(object sender, EventArgs e)
{
if (this.columnOrder == null)
{
throw new InvalidOperationException("Column order is not set");
}
else if (this.columnNames == null)
{
throw new InvalidOperationException("Column names are not set");
}
this.Font = SystemFonts.MessageBoxFont;
// Add the current columns to the top of the list, in order
foreach (int column in this.columnOrder)
{
ListViewItem addCol = new ListViewItem(this.columnNames[column]);
addCol.Name = column.ToString(CultureInfo.InvariantCulture);
addCol.Checked = true;
this.ListColumns.Items.Add(addCol);
}
// Add the rest of the columns to the list in their defined order
foreach (int column in this.columnNames.Keys)
{
if (!this.columnOrder.Contains(column))
{
ListViewItem addCol = new ListViewItem(this.columnNames[column]);
addCol.Name = column.ToString(CultureInfo.InvariantCulture);
addCol.Checked = false;
this.ListColumns.Items.Add(addCol);
}
}
}