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

ComboBox : visibility of arrow button

5 Answers 322 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Frédéric
Top achievements
Rank 1
Frédéric asked on 03 Oct 2017, 01:22 PM

Hello,

I have a grid view with a cell containing either a TextBox which is ReanOnly or a ComboBox for which the user has to select a value.

The arrow button of ComboBox cell is only visible when user clicks on cell to edit it. Thus, the user does not know if he has to select or not a value

I'd like that the arrow button of ComboBox cell is always visible to indicate to user that a value has to be selected.

I've tried to set the visibility of arrow button in EditorRequired event but it has no effect.

        void QualityControlsEntryGridView_EditorRequired(object sender, EditorRequiredEventArgs e)
        {
            if (QualityControlsEntryGridView.Columns["Result"].IsCurrent)
            {
                if (QualityControlsEntryGridView.CurrentRow.Cells["ReferenceValueToType"].Value.ToString() != "")
                {
                    e.Editor = new RadTextBoxEditor();
                    e.EditorType = typeof(RadTextBoxEditor);
                }
                else
                {
                    e.Editor = new RadDropDownListEditor();
                    e.EditorType = typeof(RadDropDownListEditor);
                    RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)((RadDropDownListEditor)e.Editor).EditorElement;
                    editorElement.ArrowButton.Visibility = ElementVisibility.Visible;
                }
            }
        }

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Oct 2017, 09:23 AM
Hello, Frédéric,  

Thank you for writing.  

Note that the editor is shown only when RadGridView enters edit mode. Only one cell can be in edit mode at a time. However, in order to indicate in the cell that the user has to select a value from a predefined list, you can refer to the following KB article: http://www.telerik.com/support/kb/winforms/details/indicate-the-editor-type-in-radgridview-columns

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
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.
0
Frédéric
Top achievements
Rank 1
answered on 04 Oct 2017, 12:50 PM

Hello Dess,

Thank you for your reply.

With the IndicatedComboBoxColumn is the arrow button displayed for all cells of the column but in my case, one column can contain a TextBox or a ComboBox and I'd like that arrow button is visible only for cells containing a ComboBox.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Oct 2017, 01:35 PM
Hello, Frédéric,   

Thank you for writing back. 

In the OnCellFormatting method of the custom GridComboBoxCellElement, the indicator element is shown/hidden considering the EnableIndicator property of the column. Here is the appropriate place to show/hide the indicator according to your custom logic. Note that you have access to the data row by the RowInfo property.

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
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.
0
Frédéric
Top achievements
Rank 1
answered on 05 Oct 2017, 05:27 AM

Hello Dess,

In the OnCellFormatting method, I've tried to retrive the type of editor and thus to set the visibility of the arrow button only if the editor is a RadDropDownListEditor.

But it does'nt work because ActiveEditor is always null.

 

        protected override void OnCellFormatting(CellFormattingEventArgs e)
        {
            base.OnCellFormatting(e);
            if (indicator != null)
            {
                bool bRadDropDownListEditor = e.CellElement.GridViewElement.ActiveEditor is RadDropDownListEditor;
                indicator.Visibility = ((IndicatedComboBoxColumn)this.ColumnInfo).EnableIndicator && bRadDropDownListEditor ? ElementVisibility.Visible : ElementVisibility.Collapsed;
            }
        }

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Oct 2017, 01:27 PM
Hello, Frédéric,   

Thank you for writing back. 

I would try to explain once again how the editing mechanism in RadGridView works. When RadGridView is not in read-only mode users can edit the contents of the current cell. Usually, this process starts by typing in the cell or by pressing F2. However, in a normal state, the grid is not in edit mode. That is why the editor is null on your end. Additional information for the editing process is available in the following section of the documentation: http://docs.telerik.com/devtools/winforms/gridview/editors/editors

Instead of checking whether the editor is active, you can store any useful information in the Tag property of the RowInfo. Thus, you can use this stored information and determine whether to show or hide the arrow.

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
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.
Tags
GridView
Asked by
Frédéric
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Frédéric
Top achievements
Rank 1
Share this question
or