This is a migrated thread and some comments may be shown as answers.

GridViewComboBoxColumn out of focus when scrolling

2 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Elad
Top achievements
Rank 1
Elad asked on 09 Dec 2012, 07:37 AM
Hi,

I'm using Telerik.WinControls.GridView version 2012.1.321.20.
I have a GridView with a GridViewComboBoxColumn, and the problem I have is that when the box is open and I click on the scroll square- than it's like the focus is out and the comboBox is closed (it's like freezing for 2 seconds and than closing...).

Also, I'm using the next definitions, as you recommended before:
public class CustomDropDownListEditor : RadDropDownListEditor
{
    protected override RadElement CreateEditorElement()
    {
        return new CustomDropDownListEditorElement();
    }
}
  
public class CustomDropDownListEditorElement : RadDropDownListEditorElement
{
    protected override RadPopupControlBase CreatePopupForm()
    {
        this.Popup = new CustomDropDownPopupForm(this);
        this.Popup.VerticalAlignmentCorrectionMode = AlignmentCorrectionMode.SnapToOuterEdges;
        this.Popup.SizingMode = this.DropDownSizingMode;
        this.Popup.Height = this.DropDownHeight;
        this.Popup.HorizontalAlignmentCorrectionMode = AlignmentCorrectionMode.Smooth;
        this.Popup.RightToLeft = this.RightToLeft ? System.Windows.Forms.RightToLeft.Yes : System.Windows.Forms.RightToLeft.Inherit;
  
        this.WirePopupFormEvents(this.Popup);
        return Popup;
    }
}
  
public class CustomDropDownPopupForm : DropDownPopupForm
{
    public CustomDropDownPopupForm(RadDropDownListElement owner): base(owner) {}
          
    public override string ThemeClassName
    {
        get { return typeof(DropDownPopupForm).FullName; }
        set {}
    }
  
    public override void ClosePopup(PopupCloseInfo info)
    {           
        base.ClosePopup(info);
        if (info.CloseReason == RadPopupCloseReason.Keyboard)
        {
            ((RadGridView)this.OwnerElement.ElementTree.Control).EndEdit();
        }
    }
  
    protected override void OnMouseUp(MouseEventArgs e)
    {
        base.OnMouseUp(e);           
        ((RadGridView)this.OwnerElement.ElementTree.Control).EndEdit();
    }
}
 
You should handle the EditorRequired event to replace the editor:
void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (e.EditorType == typeof(RadDropDownListEditor))
    {
        e.EditorType = typeof(CustomDropDownListEditor);
    }
}

What should I do in order to not loose the focus when click on scrolling? I need the user to scroll up/doun and choose another option from the list.

I'm attaching an image of my comboBox.

Thanks,
Hila.

2 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 13 Dec 2012, 05:50 PM
Hi Hila,

Thank you for writing.

If I understand your case correctly, you need to introduce the following modification to the currently employed approach:
protected override void OnMouseUp(MouseEventArgs e)
{
    base.OnMouseUp(e);
 
    if (this.OwnerDropDownListElement.ListElement.ViewElement.ControlBoundingRectangle.Contains(e.Location))
    {
        ((RadGridView)this.OwnerElement.ElementTree.Control).EndEdit();
    }         
}

This will keep the drop-down opened until there is a MouseUp that is outside the dropdown bouns. I am attaching a sample project which demonstrates the modification.

I hope that helps.

Greetings,
Plamen
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Elad
Top achievements
Rank 1
answered on 23 Dec 2012, 06:39 AM
Thanks,

that was helpful!

Hila.
Tags
GridView
Asked by
Elad
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Elad
Top achievements
Rank 1
Share this question
or