Line Separator

9 posts, 0 answers
  1. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 14 Dec 2009 Link to this post

    Dear All,

    Is it possible to have a radcomboboxitem of type separator between different items in the dropdown combo.

    Best regards.
    Waleed
  2. Nick
    Admin
    Nick avatar
    767 posts

    Posted 14 Dec 2009 Link to this post

    Hi Waleed Seada,

    Currently not, but I guess you can use dashes i.e. ----------- to represent the separator. It will be an ordinary item from RadComboBox stand-point and a special one from your application one.

    Kind regards,
    Nick
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 14 Dec 2009 Link to this post

    Hello Nick,

    It isn't working although I disabled the item, it can still be selected by arrow keys.

    Thanks
    Waleed
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 14 Dec 2009 Link to this post

    Hello Waleed Seada,

    I see, my suggestion does not work for your case then. We may consider adding a separator in future, but we have currently not planed to do so. 

    Best wishes,
    Nick
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Vinod
    Vinod avatar
    3 posts
    Member since:
    Jan 2014

    Posted 15 Jan 2014 Link to this post

    Hi,

    I do have a workaround for the problem where item separator needed in combo-box list to break down the items logically.

    Please follow underneath steps to achieve the same-

    Using below solution item separator can be applied at any preferred position in combo-box  list-

    1.  Event DropDownOpened can be used to disable the item which enforces logical separation of items present in the combo-box and set item ToolTip Text to null since separator doesn't need to be on item tooltip.

    2. KeyDown Event is used to identify the navigation of Arrow Keys( Up and Down) and ensures the separator should not be selected by any means.

      void comboBox3_DropDownOpened(object sender, EventArgs e)
            {
                foreach (var item in comboBox3.Items)
                {
                    if (item.Text.Contains("---"))
                    {
                        item.Enabled = false;
                        item.ToolTipText = null;

                    }
                }


      void comboBox3_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyValue == 38 || e.KeyValue == 40)
                {
                    RadItem selectedItem = comboBox3.SelectedItem as RadItem;
                    if (selectedItem != null)
                    {
                        if (selectedItem.Text.Contains("---"))
                        {
                            int currentIndex = comboBox3.SelectedIndex;
                            int itemsCount = comboBox3.Items.Count - 1;


                            if (e.KeyValue == 40) //KeyDown                     
                            {
                                if (currentIndex != itemsCount)
                                    currentIndex += 1;
                                else
                                    currentIndex -= 1;
                            }
                            else if (e.KeyValue == 38)//KeyUp
                                currentIndex -= 1;

                            if (currentIndex != 0)
                            {
                                comboBox3.SelectedIndex = currentIndex;
                                selectedItem.ForceReApplyStyle();
                            }

                        }
                    }
                }
            }


    This may help!!!!!

    Note : Above solution addresses the problem in Version 8.2.0.0

    Best Regards
    Vinod

          
  7. Vinod
    Vinod avatar
    3 posts
    Member since:
    Jan 2014

    Posted 16 Jan 2014 Link to this post

    Amended the solution for consecutive item separators.

      void comboBox3_KeyDown(object sender, KeyEventArgs e)
            {
                this.SetNextOrPreviousElements(e);
            }

            void SetNextOrPreviousElements(KeyEventArgs e)
            {
                if (e.KeyValue == 38 || e.KeyValue == 40)
                {
                    RadItem selectedItem = comboBox3.SelectedItem as RadItem;
                    if (selectedItem != null)
                    {
                        selectedItem.ForceReApplyStyle();

                        if (selectedItem.Text.Contains("----"))
                        {
                            int nextOrPrevious = 0;
                            int currentIndex = comboBox3.SelectedIndex;
                            int itemsCount = comboBox3.Items.Count - 1;

                            while (true) // For consecutive Item separators
                            {
                                if (e.KeyValue == 40) //KeyDown                     
                                {
                                    if (currentIndex < itemsCount)
                                    {
                                        if ((comboBox3.Items[currentIndex] as RadItem).Text.Contains("----"))
                                        {
                                            currentIndex += 1;
                                            nextOrPrevious++;
                                        }
                                        else
                                            break;
                                    }
                                    else
                                    {
                                        currentIndex -= nextOrPrevious + 1;
                                        break;
                                    }
                                }

                                else if (e.KeyValue == 38)//KeyUp
                                {
                                    if (currentIndex > -1)
                                    {
                                        if ((comboBox3.Items[currentIndex] as RadItem).Text.Contains("----"))
                                        {
                                            currentIndex -= 1;
                                            nextOrPrevious++;
                                        }
                                        else
                                            break;
                                    }
                                    else
                                    {
                                        currentIndex += nextOrPrevious + 1;
                                        break;
                                    }
                                }
                            }
                                comboBox3.SelectedIndex = currentIndex;
                                selectedItem.ForceReApplyStyle();
                            }
                    }
                }
            }



            void comboBox3_DropDownOpened(object sender, EventArgs e)
            {
                foreach (var item in comboBox3.Items)
                {
                    if (item.Text.Contains("----"))
                    {
                        item.Enabled = false;
                        item.ToolTipText = null;

                    }
                }
            }

    Thanks!!!!!
  8. George
    Admin
    George avatar
    500 posts

    Posted 20 Jan 2014 Link to this post

    Hello Vinod,

    Thank you for writing.

    From your reply it did not become clear if you have resolved your problem. If you have not, I would like to kindly ask you to provide me with more details about what exactly is your current problem.

    Let me know if you need further assistance.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  9. Vinod
    Vinod avatar
    3 posts
    Member since:
    Jan 2014

    Posted 20 Jan 2014 Link to this post

    Hello This resolves the issue where an item separator is required in combo-box to group the items logically. I just tried seeking the in-built solution in the current version(using in my project) I mentioned in my earlier post but not found any. Therefore tried some customised solution to resolve it since there was such requirement exist in my project. Though I have optimized the solution which I may post tomorrow. Thanks
  10. George
    Admin
    George avatar
    500 posts

    Posted 23 Jan 2014 Link to this post

    Hello Vinod,

    I am glad that you have found a resolution for your problem.

    Do not hesitate to contact us, should you have any questions.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready