private void expressionGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (expressionGrid.Columns[e.ColumnIndex] == this.EditorColumn) { DataGridViewRow row = expressionGrid.Rows[e.RowIndex]; DataGridViewButtonDisableCell cell = (DataGridViewButtonDisableCell)row.Cells[this.EditorColumn.Index]; if (cell.Enabled) { OnRaiseEditExpressionSelected( new EditExpressionSelectedEventArgs(row.Tag as Type, row.Cells[expressionGrid.Columns["ObjectPath"].Index].Value.ToString(), row.Cells[expressionGrid.Columns["Expression"].Index].Value as string, row.Cells[expressionGrid.Columns["Property"].Index].Value.ToString(), row.Cells[expressionGrid.Columns["ContainerID"].Index].Value.ToString(), row.Cells[expressionGrid.Columns["ObjectID"].Index].Value.ToString())); } } } catch (Exception ex) { MessageBox.Show("Error occured while editing the expression: " + ex.Message); } }
public void AddValue(Type type, string containerID, string objectID, string objectType, string objectPath, string objectName, string propertyName, string value, Icon icon, bool isExpression) { // containerID, objectID, objectName are hidden columns. string[] newRow = { containerID, objectID, objectType, objectPath, objectName, propertyName, value }; int index = expressionGrid.Rows.Add(newRow); DataGridViewRow row = expressionGrid.Rows[index]; row.Tag = type; row.Cells["ObjectType"].Tag = icon; if (!isExpression) { DataGridViewButtonDisableCell buttonCell = (DataGridViewButtonDisableCell)row.Cells["EditorColumn"]; buttonCell.Enabled = false; } }