MySql.Data.VisualStudio.Editors.IndexColumnEditorDialog.indexGrid_EditingControlShowing C# (CSharp) Method

indexGrid_EditingControlShowing() private method

private indexGrid_EditingControlShowing ( object sender, System.Windows.Forms.DataGridViewEditingControlShowingEventArgs e ) : void
sender object
e System.Windows.Forms.DataGridViewEditingControlShowingEventArgs
return void
    private void indexGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
      Type t = e.Control.GetType();
      if (t != typeof(DataGridViewComboBoxEditingControl)) return;

      DataGridViewComboBoxEditingControl ec = e.Control as DataGridViewComboBoxEditingControl;
      ec.DrawMode = DrawMode.OwnerDrawFixed;
      ec.DrawItem += new DrawItemEventHandler(dropdown_DrawItem);

      if (indexGrid.CurrentCell.ColumnIndex == 0)
      {
        // now we need to set the item list to all non used columns and the option of 
        // NONE
        ec.Items.Clear();
        ec.Items.Add("<None>");
        foreach (string s in columnNames)
        {
          bool alreadyUsed = false;
          if (s != (string)indexGrid.CurrentRow.Cells[0].Value)
            foreach (IndexColumnGridRow row in gridRows)
              if (row.ColumnName == s)
              {
                alreadyUsed = true;
                break;
              }
          if (!alreadyUsed)
            ec.Items.Add(s);
        }
        int index = ec.FindStringExact(indexGrid.CurrentRow.Cells[0].Value as string);
        if (index > 0)
          ec.SelectedIndex = index;
      }
    }