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

Line Separator

8 Answers 275 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Waleed Seada
Top achievements
Rank 2
Waleed Seada asked on 14 Dec 2009, 07:42 AM
Dear All,

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

Best regards.
Waleed

8 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 14 Dec 2009, 07:53 AM
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.
0
Waleed Seada
Top achievements
Rank 2
answered on 14 Dec 2009, 08:10 AM
Hello Nick,

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

Thanks
Waleed
0
Nick
Telerik team
answered on 14 Dec 2009, 08:40 AM
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.
0
Vinod
Top achievements
Rank 1
answered on 16 Jan 2014, 04:38 AM
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

      
0
Vinod
Top achievements
Rank 1
answered on 16 Jan 2014, 06:43 AM
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!!!!!
0
George
Telerik team
answered on 20 Jan 2014, 02:26 PM
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 >>
0
Vinod
Top achievements
Rank 1
answered on 20 Jan 2014, 02:44 PM
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
0
George
Telerik team
answered on 23 Jan 2014, 10:43 AM
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 >>
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Waleed Seada
Top achievements
Rank 2
Answers by
Nick
Telerik team
Waleed Seada
Top achievements
Rank 2
Vinod
Top achievements
Rank 1
George
Telerik team
Share this question
or