Yes you can dynamically provide dropdown style of editor for specific rows.
Create new class inherited from Dropdownlistcolumn and override EditorStyle property:
[c#]
/*-------------------------------------------------------------------------
There are two classes, DynamicDropDownListColumn dynamically returns EditorStyle,
AdvDropDownListColumn - dynamically shows dropdown buttons next to the dropdownlist column.
Usage:
AdvDropDownListColumn ddCol = new AdvDropDownListColumn(\"DynamicDDColumn\");
ddCol.ShowDropDownButtons = true;
//--connect to GetEditorStyle event
ddCol.GetEditorStyle += new DynamicDropDownListColumn.GetEditorStyleHandler(ddCol_GetEditorStyle);
//--GetEditorStyle event Handler:
private EditorStyle ddCol_GetEditorStyle(object sender, NodeBase node)
{
return node.Index == 0 ? EditorStyle.DropDown : EditorStyle.Simple;
}
-------------------------------------------------------------------------*/
public class DynamicDropDownListColumn : DropDownListColumn
{
public DynamicDropDownListColumn(string caption) : base(caption){}
public delegate EditorStyle GetEditorStyleHandler(object sender, NodeBase node);
public event GetEditorStyleHandler GetEditorStyle;
public virtual EditorStyle OnGetEditorStyle(NodeBase node)
{
if (node != null && GetEditorStyle != null)
return GetEditorStyle(this, node);
return base.EditorStyle;
}
public override EditorStyle EditorStyle
{
get
{
FlyGrid flyGrid = this.Owner.GetOwner();
return OnGetEditorStyle(flyGrid != null ? flyGrid.Selected : null);
}
set
{
base.EditorStyle = value;
}
}
}
public class AdvDropDownListColumn : DynamicDropDownListColumn
{
public AdvDropDownListColumn(string caption) : base(caption){}
private bool showDropDownButtons = false;
[DefaultValue(false)]
public bool ShowDropDownButtons
{
get
{
return showDropDownButtons;
}
set
{
if (showDropDownButtons != value)
{
showDropDownButtons = value;
base.OnChanged(InvalidationMode.ColumnWithoutHeader, false);
}
}
}
public override Rectangle GetEditableCellRect(FlyGridViewPort context, FlyGridViewPort grid, NodeBase node)
{
Rectangle er = base.GetEditableCellRect (context, grid, node);
EditorStyle edStyle = OnGetEditorStyle(node);
if (showDropDownButtons && (edStyle == EditorStyle.DropDown || edStyle == EditorStyle.DropDownResizable))
{
er.Width -= SystemInformation.VerticalScrollBarWidth;
}
return er;
}
public override void PaintCell(CellDrawInfo dci)
{
Rectangle buttonRect = dci.cellRect;
EditorStyle edStyle = OnGetEditorStyle(dci.node);
bool showButtons = showDropDownButtons && (edStyle == EditorStyle.DropDown || edStyle == EditorStyle.DropDownResizable);
if (showButtons)
{
dci.cellRect.Width -= SystemInformation.VerticalScrollBarWidth;
}
base.PaintCell (dci);
if (showButtons)
{
buttonRect = new Rectangle(buttonRect.Right - SystemInformation.VerticalScrollBarWidth, buttonRect.Y, SystemInformation.VerticalScrollBarWidth, buttonRect.Height);
ControlPaint.DrawComboButton(dci.g, buttonRect, ButtonState.Normal);
}
}
}