repositoryItemComboBox控件的使用(转)

DevExpress中的repositoryItemComboBox控件得到索引值和选项值

有时候会在界面中使用下拉框,并且这种下拉框的属性为DevExpress.XtraEditors.Repository.RepositoryItemComboBox,这种下拉框该如何得到索引值和选项值呢?

添加下拉框选项

repositoryItemComboBox1.Items.Add("1");
repositoryItemComboBox1.Items.Add("2");
repositoryItemComboBox1.Items.Add("3");
1
2
3
设置初始值

一般显示的是如图所示,那么该如何使其又初始值呢,笔直查看了其方法并没有找到,后来查看官方文档时发现可以使用其上一层级的控件,barEditItem1设置,代码如下:

barEditItem1.EditValue = "2";//使用其上一层级的控件EditValue方法
1
3.获得下框的选定值

string str = barEditItem1.EditValue.ToString();
MessageBox.Show("选项值:" + str);
int num=repositoryItemComboBox1.Items.IndexOf(str);
MessageBox.Show("索引值:" + num.ToString());
1
2
3
4


原文链接:https://blog.csdn.net/endlessseaofcrow/article/details/78595707

posted on 2024-06-24 09:13  xihong  阅读(4)  评论(0编辑  收藏  举报

导航