this.dataGrid.Model.CellModels.Remove("FilterBarCell");
this.dataGrid.Model.CellModels.Add("FilterBarCell", new GridFilterBarCellModelExt());
. . .
public class GridFilterBarCellModelExt : GridCellModel<GridCellTextBoxRendererExt>
{
}
public class GridCellTextBoxRendererExt: GridDataFilterBarCellRenderer
{
public GridCellTextBoxRendererExt():base()
{
}
protected override void OnRender(DrawingContext dc, RenderCellArgs rca, GridRenderStyleInfo style)
{
if (rca.CellUIElements != null)
return;
var margins = style.TextMargins.ToThickness();
if (style.HasImageIndex)
{
margins = style.AdjustImageWidthAndHeightToMargin(margins, rca.CellRect.Size);
}
else
{
margins = style.ErrorInfo.AdjustErrorInfoMargin(margins, rca.CellRect.Size);
}
Rect textRectangle = rca.SubtractBorderMargins(rca.CellRect, margins);
if (textRectangle.IsEmpty)
return;
margins.Left = Math.Max(margins.Left, 2);
margins.Right = Math.Max(margins.Right, 2);
string text = GetControlText(style);
if (text == string.Empty)
text = "Type to filter";
GridTextBoxPaint.DrawText(dc, textRectangle, text, style);
}
} |