GridViewComboBoxColumn Editor Alignment

2 posts, 0 answers
  1. David
    David avatar
    3 posts
    Member since:
    Jun 2017

    Posted 20 Jun 2017 Link to this post

    I have a GridViewComboBoxColumn and while in edit mode I want the StretchVertically to be false so I use the following code:

    this.radGridView1.CellBeginEdit += RadGridView1_CellBeginEdit;

    private void RadGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
    switch (e.Column.Name)
    case "MyColumn":
    RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
    if (editor != null)
    editor.EditorElement.StretchVertically = false;
    editor.EditorElement.Alignment = ContentAlignment.TopLeft;

    But the dropdownlisteditor is still vertically centered in the cell. Is there a way to have it TopLeft?

  2. Dimitar
    Dimitar avatar
    2832 posts

    Posted 21 Jun 2017 Link to this post

    Hello David,

    You need to create a custom column and override the ArrangeEditorElement method. Here is a sample implementation:
    public class CustomColumn : GridViewComboBoxColumn
        public override Type GetCellType(GridViewRowInfo row)
            if (row is GridViewDataRowInfo)
                return typeof(MyCell);
            return base.GetCellType(row);
    class MyCell : GridComboBoxCellElement
        public MyCell(GridViewColumn col, GridRowElement row) : base(col, row)
        { }
        protected override Type ThemeEffectiveType
                return typeof(GridComboBoxCellElement);
        protected override void ArrangeEditorElement(SizeF finalSize, RectangleF clientRect)
            RadElement element = this.GetEditorElement(Editor);
            float editorHeight = element.DesiredSize.Height;
            if (element.StretchVertically)
                editorHeight = clientRect.Height;
            editorHeight = Math.Min(editorHeight, finalSize.Height);
            if (ViewTemplate.ViewDefinition is HtmlViewDefinition && ControlBoundingRectangle.X < 0)
                clientRect.X += -ControlBoundingRectangle.X;
            RectangleF editorRect = new RectangleF(clientRect.X, clientRect.Y, clientRect.Width, editorHeight);

    Please let me know if there is something else I can help you with. 
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top