Hi
I am getting this error on attempting cell edit. (See attached)
Any ideas how to fix?
This is the code I am using which works fine when loading the data into the grid
using System;
using System.Collections.Generic;
using System.Data;
using Wisej.Web;
namespace wjServiceDirectory
{
public class DataGridViewMultiComboBoxColumn : DataGridViewComboBoxColumn
{
public DataGridViewMultiComboBoxColumn() : base()
{
this.Editor = new DataGridViewMccbEditor();
}
}
public class DataGridViewMultiComboBoxColumnCell : DataGridViewComboBoxCell
{
public DataGridViewMultiComboBoxColumnCell()
{
Control = new MultiColumnComboBox()
{
//DropDownRows = 16,
//ColumnVisible = new List { true, true, true, true, true, false },
//ColumnWidths = new List { 80, 250, 250, 200, 80, 0 },
//KeyColumn = 0,
//DisplayColumn = 1,
//Border = BorderStyle.None,
Dock = DockStyle.Fill,
};
//this.Style.ForeColor = System.Drawing.Color.Transparent;
}
public void MultiCombo_SelectionMade(object sender, EventArgs e)
{
Value = ((MultiColumnComboBox)sender).BoundValue;
}
public override Type FormattedValueType
{
get { return typeof(string); }
}
public override Type ValueType
{
get { return typeof(string); }
set { }
}
protected override bool SetValue(object value)
{
((MultiColumnComboBox)this.Control).BoundValue = value;
return base.SetValue(value);
}
}
public class DataGridViewMccbEditor : MultiColumnComboBox, IDataGridViewEditingControl
{
public DataGridView DataGridView { get; set; }
public bool Invalid
{
get { return false; }
}
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle style)
{
}
public string GetEditingControlFormattedValue()
{
return this.BoundValue.ToString();
}
public void PrepareEditingControlForEdit(bool selectAll)
{
DataGridViewMultiComboBoxColumn cmb = this.DataGridView.CurrentCell.OwningColumn as DataGridViewMultiComboBoxColumn;
DataTable dtMcc = ((DataTable)cmb.DataSource).Copy();
DropDownRows = 16;
ColumnVisible = new List { true, true, true, true, true, false };
ColumnWidths = new List { 80, 250, 250, 200, 80, 0 };
KeyColumn = 0;
DisplayColumn = 1;
Border = BorderStyle.None;
Dock = DockStyle.Fill;
refreshMCC(dtMcc);
this.BoundValue = this.DataGridView.CurrentCell.Value;
}
}
Thanks for your help Ewan
It expects an editable control. The code is using a panel.
Please login first to submit.