public void ReverseAllCheckStatus()
 {
     base.FindForm().Cursor = Cursors.WaitCursor;
     MyCheckedListBox.BeginUpdate();
     for (int i = 0; i < MyCheckedListBox.Items.Count; i++)
     {
         MyCheckedListBox.SetItemChecked(i, !MyCheckedListBox.GetItemChecked(i));
     }
     MyCheckedListBox.EndUpdate();
     base.FindForm().Cursor = Cursors.Default;
 }
        private void CheckFromFileMenuItem_Click(object sender, System.EventArgs e)
        {
            FileServer fs;
            string     filename;

            string[] loadedItems;
            bool     isUnknownItem;

            try
            {
                //Get file name.
                MyOpenFileDialog.ShowDialog();
                filename = MyOpenFileDialog.FileName;
                if (filename == "")
                {
                    return;
                }

                base.FindForm().Cursor = Cursors.WaitCursor;
                //Load file.
                fs          = new FileServer();
                loadedItems = fs.ReadSingleColumn(filename);
                if (loadedItems.GetLength(0) < 1)
                {
                    base.FindForm().Cursor = Cursors.Default;
                    return;
                }

                //See if there are loaded items which are not
                //in the checked list box.
                for (int i = 0; i < loadedItems.GetLength(0); i++)
                {
                    isUnknownItem = true;
                    for (int j = 0; j < MyCheckedListBox.Items.Count; j++)
                    {
                        if (MyCheckedListBox.Items[j].ToString().ToUpper() == loadedItems[i].ToUpper())
                        {
                            isUnknownItem = false;
                            break; //Exit for.
                        }
                    }
                    if (isUnknownItem)
                    {
                        base.FindForm().Cursor = Cursors.Default;
                        MessageManager.ShowWarning("The item " + loadedItems[i] +
                                                   " in the file is not present in the list.", base.FindForm());
                        return;
                    }
                }

                //Check the loaded items.
                for (int i = 0; i < loadedItems.GetLength(0); i++)
                {
                    for (int j = 0; j < MyCheckedListBox.Items.Count; j++)
                    {
                        if (MyCheckedListBox.Items[j].ToString().ToUpper() == loadedItems[i].ToUpper())
                        {
                            MyCheckedListBox.SetItemChecked(j, true);
                            break; //Exit for.
                        }
                    }
                }
                base.FindForm().Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageManager.ShowError(ex, "Unable to check items from file.", base.FindForm());
            }
        }