Hi Nicolas,
Thanks for your interest in Syncfusion products.
In order to apply the format for display member of the ComboBox , you need to customize the GridComboBoxCellModel and GidComboBoxCellRenderer. Please make use of the below code,
Code example
this.gridGroupingControl1.TableModel.CellModels.Add("CustomComboBox", new GridComboBoxCellModelAdv(this.gridGroupingControl1.TableModel));
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.CellType = "CustomComboBox";
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.DataSource = GetTable();
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.DisplayMember = "Value";
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.ValueMember = "ID";
this.gridGroupingControl1.TableDescriptor.Columns["Description"].Appearance.AnyRecordFieldCell.Format = "dd/MM/yy";
//Custom_ComboBoxCellModel:
public class GridComboBoxCellModelAdv : GridComboBoxCellModel
{
public GridComboBoxCellModelAdv(GridModel grid)
: base(grid)
{
AllowFloating = false;
ButtonBarSize = new Size(SystemInformation.VerticalScrollBarWidth, 0);
SupportsChoiceList = true;
}
public override GridCellRendererBase CreateRenderer(GridControlBase control)
{
return new GridComboBoxCellRendererAdv(control, this);
}
public override string GetFormattedText(GridStyleInfo style, object value, int textInfo)
{
if (style.Format != string.Empty)
{
DateTime date = new DateTime();
if (DateTime.TryParse(base.GetFormattedText(style, value, textInfo), out date))
{
value = date.ToString(style.Format);
}
else if (style.CellValueType == typeof(string))
{
value = string.Format("{0:" + style.Format + "}", base.GetFormattedText(style, value, textInfo));
}
}
return base.GetFormattedText(style, value, textInfo);
}
}
//Custom_ComboBoxCellRenderer:
public class GridComboBoxCellRendererAdv : GridComboBoxCellRenderer
{
public GridComboBoxCellRendererAdv(GridControlBase grid, GridCellModelBase cellModel)
: base(grid, cellModel)
{
DropDownImp.InitFocusEditPart = true;
DropDownButton = new GridCellComboBoxButton(this);
}
protected override void OnSetControlText(string text)
{
if (StyleInfo.Format != string.Empty)
{
DateTime date = new DateTime();
if (DateTime.TryParse(text, out date))
{
text = date.ToString(StyleInfo.Format);
}
else if (StyleInfo.CellValueType == typeof(string))
{
text = string.Format("{0:" + StyleInfo.Format + "}", text);
}
}
base.OnSetControlText(text);
}
}
Sample link
Regards,
Piruthiviraj