private void DataGridViewIntegration_Load(object sender, EventArgs e) { if (!DesignMode) { // Set first columns for evaluate expression var expressionColumns = new List <string>() { "EmptyExpression", "Expression" }; expressionColumns.ToList() .ForEach(x => { dataGridView1.Columns.Add(x, x); dataGridView1.Columns[x].DefaultCellStyle.ForeColor = Color.FromArgb(102, 51, 0); }); // Set data source dataGridView1.DataSource = DataSources.GetProducts();; this.BeginInvoke((Action)(() => { // Evaluate expression column dataGridView1.UpdateExpression("Expression", "[UnitPrice] * [UnitsInStock]"); })); } }
private void FlexGridIntegration_Load(object sender, EventArgs e) { // Set data source c1FlexGrid1.DataSource = DataSources.GetProducts(); // Add a calculated column var expressionColumn = c1FlexGrid1.Cols.Insert(1); // The Name property for expression column should be set expressionColumn.Name = _expressionColumnName; expressionColumn.DataType = typeof(object); expressionColumn.Caption = _expressionColumnName; expressionColumn.AllowEditing = false; // Allow editing expression in run-time (expression icon in column header) expressionColumn.AllowExpressionEditing = true; expressionColumn.Style.ForeColor = Color.FromArgb(102, 51, 0); // Set expression expressionColumn.Expression = "[UnitPrice] * [UnitsInStock]"; c1FlexGrid1.AutoSizeCols(); }