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

Changing DropDownWidth of RadDropDownListEditorElement for GridViewComboBoxColumn

1 Answer 138 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mimi
Top achievements
Rank 1
Mimi asked on 28 Jan 2019, 11:04 PM

Hello,

I'm having some trouble changing the width of the editor for a gridViewComboBoxColumn. I'm using a RadDropDownListEditor. I took a look at this thread: https://www.telerik.com/forums/resize-combobox-27cd57e8088b from several years back but this method still didn't work for me. Below is what I have tried. What am I doing wrong? The dropdownwidth still remains the width of the column no matter what I try.

        private void radGridViewDetail_EditorRequired(object sender, EditorRequiredEventArgs e)
        {
            switch (radGridViewDetail.CurrentColumn.Name)
            {
                case "CO":
                case "CC":
                case "Acct":
                    e.Editor = new RadDropDownListEditor();
 
                    break;
            }
        }

        private void radGridViewDetail_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        {
            if (e.ActiveEditor is RadDropDownListEditor)
            {
                //RadDropDownListEditor editor = (RadDropDownListEditor)e.ActiveEditor;
                RadDropDownListEditor editor = this.radGridViewDetail.ActiveEditor as RadDropDownListEditor;
                if (editor != null)
                {
                    RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement;
                    element.DropDownSizingMode = SizingMode.UpDownAndRightBottom; // This does not work
                    element.PopupOpened += new EventHandler(editorElement_PopupOpened);
                    //((RadDropDownListEditorElement)((RadDropDownListEditor)this.radGridViewDetail.ActiveEditor).EditorElement).DropDownSizingMode = SizingMode.RightBottom;
                    //((RadDropDownListEditorElement)((RadDropDownListEditor)this.radGridViewDetail.ActiveEditor).EditorElement).DropDownMinSize = new Size(200, 100);
                    //((RadDropDownListEditorElement)((RadDropDownListEditor)this.radGridViewDetail.ActiveEditor).EditorElement).Popup.Width = 200;
                    element.DropDownMinSize = new Size(200, 100);
                    element.ArrowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; // This works
                    //element.AutoCompleteMode = AutoCompleteMode.SuggestAppend; // This isn't needed
                    element.Popup.Width = 200;
                    element.DropDownWidth = 200;
                    
                    switch (radGridViewDetail.CurrentColumn.Name)
                    {
                        case "CO":
                            element.AutoCompleteDataSource = coTable;
                            element.AutoCompleteDisplayMember = "COMPANY_CODE";
                            element.AutoCompleteValueMember = "COMPANY_CODE";
                            element.DropDownWidth = 200;
                            break;
                        case "CC":
                            element.AutoCompleteDataSource = ccTable;
                            element.DisplayMember = "ADDRESS";
                            element.ValueMember = "COST_CENTER";
                            element.AutoCompleteDisplayMember = "ADDRESS";
                            element.AutoCompleteValueMember = "COST_CENTER";
                            break;
                        case "Acct":
                            element.AutoCompleteDataSource = glTable;
                            element.DisplayMember = "ACCT_DESC";
                            element.ValueMember = "GLMAJOR";
                            element.AutoCompleteDisplayMember = "ACCT_DESC";
                            element.AutoCompleteValueMember = "GLMAJOR";
                            break;
                    }
                }
            }
        }

        private void editorElement_PopupOpened(object sender, EventArgs e)
        {
            ((RadDropDownListEditorElement)sender).Popup.MinimumSize = new Size(150, 0);
        }

 


1 Answer, 1 is accepted

Sort by
0
Mimi
Top achievements
Rank 1
answered on 28 Jan 2019, 11:38 PM

Nevermind! I figured what it was.

element.AutoCompleteSuggest.DropDownList.DropDownMinSize = new Size(275, 100);

Tags
GridView
Asked by
Mimi
Top achievements
Rank 1
Answers by
Mimi
Top achievements
Rank 1
Share this question
or