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

problem in dropdownlistelement after collapsing ribbonbar

1 Answer 58 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Mahesh V
Top achievements
Rank 2
Mahesh V asked on 24 Dec 2013, 06:05 AM
 I have a ribbon bar. It has ribbonbarbuttongroup and it has different elements like dropdownlistelement etc. we are creating  dropdownlistelements at run time. We are populating dropdownlistelements on form load. On form load, we are also hiding ribbon tab using '
this.radribbonbar1.RibbonBarElement.Expanded = false;'. After execution of this line,  dropdownlistelement's items count has become 0 during debugging though items are showing in it. So its creating problem when we loop through dropdownlistelement.
When i manually expand/collapse ribbon bar multiple times again items count become 0. One more thing, Suppose i selected some text in
dropdownlistelement and expand/collapse ribbon bar one/two times, text is showing selected but during debugging no item is selected (When we loop through).





1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 26 Dec 2013, 08:30 AM
Hello Shantosh,

Thank you for contacting Telerik Support.

I am guessing that you are not directly adding items, instead you are assigning a DataSource to the RadDropDownListElement. If that is the case then this behavior is normal since the RadDropDownListElement tries to cache the values whenever possible, that is why the items are in the Items collection when the RibbonBarElement is expanded. As a workaround you can use the DataSource which you are assigning and iterate over it. For example if your DataSource is a List of integers you can cast the DataSource property of the RadDropDownListElement and iterate it.

The caching and reusing of the data also raises the matter with the selected item. One possible way to workaround this behavior is to subscribe to the SelectedIndexChanged of the RadDropDownList and in a variable or other more advanced caching method to save the last selected item if the selected index is not -1. This way even when the ribbon is collapsed you will know what your selected item is.

I am attaching a sample project which demonstrates this above described functionality.

If you have any further questions or queries, do not hesitate to contact us.

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
RibbonBar
Asked by
Mahesh V
Top achievements
Rank 2
Answers by
George
Telerik team
Share this question
or