// Override the Clone method so that the Enabled property is copied. public override object Clone() { DataGridViewDisableButtonCell cell = (DataGridViewDisableButtonCell)base.Clone(); cell.Enabled = this.Enabled; return(cell); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewDisableButtonCell) { DataGridViewDisableButtonCell buttonCell = (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewDisableButtonCell); if (buttonCell.Enabled) { Cursor.Current = Cursors.WaitCursor; if (buttonCell.Tag is VSCodeSnippet) { if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == removeCaption) { (buttonCell.Tag as VSCodeSnippet).Remove(); } else { (buttonCell.Tag as VSCodeSnippet).Install(); } } else if (buttonCell.Tag is VSECodeSnippet) { if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == removeCaption) { (buttonCell.Tag as VSECodeSnippet).Remove(); } else { (buttonCell.Tag as VSECodeSnippet).Install(); } } else if (buttonCell.Tag is VSE9CodeSnippet) { if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == removeCaption) { (buttonCell.Tag as VSE9CodeSnippet).Remove(); } else { (buttonCell.Tag as VSE9CodeSnippet).Install(); } } else if (buttonCell.Tag is VS10Toolbar) { (buttonCell.Tag as VS10Toolbar).Install(); } else { CSSToolbar toolbar; if (e.RowIndex == 0) { toolbar = vsToolbar; } else if (e.RowIndex == 1) { toolbar = vsExpressToolbar; } else if (e.RowIndex == 2) { toolbar = vs9Toolbar; } else if (e.RowIndex == 3) { toolbar = vsExpress9Toolbar; } else if (e.RowIndex == 4) { toolbar = vs10Toolbar; } else { toolbar = vsExpress10Toolbar; } if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == removeCaption && toolbar.IsRestoreAvailable) { toolbar.RestoreOldSettings(); } else if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == insertCaption && !toolbar.IsInstalled) { toolbar.Install(); } else if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == importCaption && !toolbar.IsInstalled) { toolbar.Import(); } } RefreshLayout(); Cursor.Current = Cursors.Default; } } }