RadDropDownListEditorElement Items visible

2 posts, 0 answers
  1. Вадим
    Вадим avatar
    21 posts
    Member since:
    Mar 2016

    Posted 26 Jun 2018 Link to this post

    private void radGridView5_CellEditorInitialized(object sender, GridViewCellEventArgs e)
            {
                if (e.Column.Name == "operati")
                {
                    RadDropDownListEditor editors = (RadDropDownListEditor)e.ActiveEditor;
                    RadDropDownListEditorElement elements = (RadDropDownListEditorElement)editors.EditorElement;
     
                    switch (_endOperationSoc)
                    {
                        case "принят":
                            elements.Items.RemoveAt(4);
                            elements.Items.RemoveAt(1);
                            break;
                        case "приостановлен":
                            elements.Items.RemoveAt(3);
                            elements.Items.RemoveAt(1);
                            break;
                        case "снят":
                            elements.Items.RemoveAt(4);
                            elements.Items.RemoveAt(3);
                            elements.Items.RemoveAt(2);
                            break;
                        case "возобновлен":
                            elements.Items.RemoveAt(4);
                            elements.Items.RemoveAt(1);
                            break;
                    }
                }
     
                if (e.Column.HeaderText == "соц. работник")
                {
                    RadDropDownListEditor editors = (RadDropDownListEditor)e.ActiveEditor;
                    RadDropDownListEditorElement elements = (RadDropDownListEditorElement)editors.EditorElement;
                    if (radGridView5.RowCount != 0)
                        elements.SelectedIndex = elements.FindString(radGridView5.Rows[radGridView5.RowCount - 1].Cells[1].Value.ToString());
                }
     
                RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
     
                if (editor == null)
                {
                    return;
                }
     
                RadDropDownListElement element = editor.EditorElement as RadDropDownListEditorElement;
     
                int scrolBarWidth = 0;
     
                if (element.DefaultItemsCountInDropDown < element.Items.Count)
                {
                    scrolBarWidth = 35;
                }
     
                foreach (RadListDataItem item in element.Items)
                {
                    string text = item.Text;
                    Size size = TextRenderer.MeasureText(text, element.Font);
     
                    if (element.DropDownWidth < size.Width)
                    {
                        element.DropDownWidth = size.Width + scrolBarWidth;
                    }
                }
            }

    here is this moment:

    switch (_endOperationSoc)
                    {
                        case "принят":
                            //elements.Items[4].IsVisible = false;
                            elements.Items.RemoveAt(4);
                            elements.Items.RemoveAt(1);
                            RadMessageBox.Show("принят", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                            break;
                        case "приостановлен":
                            elements.Items.RemoveAt(3);
                            elements.Items.RemoveAt(1);
                            RadMessageBox.Show("приостановлен", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                            break;
                        case "снят":
                            elements.Items.RemoveAt(4);
                            elements.Items.RemoveAt(3);
                            elements.Items.RemoveAt(2);
                            RadMessageBox.Show("снят", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                            break;
                        case "возобновлен":
                            elements.Items.RemoveAt(4);
                            elements.Items.RemoveAt(1);
                            RadMessageBox.Show("возобновлен", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                            break;
                    }
                }

    How do I not delete items but just hide or display them?
    It is necessary to do it in this moment.
    Thank you.

     

  2. Dimitar
    Admin
    Dimitar avatar
    2960 posts

    Posted 27 Jun 2018 Link to this post

    Hello Vadim,

    The only other way is to set the Height of the items:
    RadDropDownListEditor editor = (RadDropDownListEditor)e.ActiveEditor;
    if (editor != null)
    {
        RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement;
        element.Items[0].Height = 0;
    }

    I hope this will be useful. 

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 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