[英]Add Items in RadComboBox dynamically in C#
I'm trying to add Items
to RadComboBox
dynamically. 我正在尝试将Items
动态添加到RadComboBox
。 It's supposed to work like this: I have an editable RadComboBox
and a Button
. 它应该像这样工作:我有一个可编辑的RadComboBox
和一个Button
。 Any text I type into RadComboBox
should be saved as a new Item
on a Button_Click
and I should be able to see it in a dropdown list and select it. 我键入RadComboBox
所有文本都应另存为Button_Click
上的新Item
,并且我应该能够在下拉列表中看到它并选择它。 Thank you for your help. 谢谢您的帮助。
First, I would like you to read this in the Telerik documentation: docs 首先,我希望您在Telerik文档中阅读以下内容: docs
It will help you understand how bindings work for the RadComboBox. 它将帮助您了解RadComboBox的绑定如何工作。
How would I solve your problem? 我将如何解决您的问题? I'd follow these steps: 我将按照以下步骤操作:
ObservableCollection<Item>
. 将您的RadComboBox绑定到ObservableCollection<Item>
。 Make sure that Item
implements onPropertyChanged()
确保Item
实现onPropertyChanged()
Item
and add it to your ObservableCollection<Item>
. 在上述情况下,请创建一个Item
并将其添加到您的ObservableCollection<Item>
。 If you have a problem following any of those steps, put a comment below and I'll try to help. 如果您在执行上述任何步骤时均遇到问题,请在下面添加评论,我将尽力提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.