在开发中遇到这样一个问题,使用devexpress的combobox可以顺利的获取到index,但当在treelist或datagrid中使用repositoryitemcombobox时却无法正常使用combobox下的一些方法与属性。

特别是准备使用selectindex时更是麻烦。上官网搜索到如下使用方法,留个记录。

http://community.devexpress.com/forums/t/12931.aspx

 

You can set the selected index property of the RepositoryItemComboBox in the InitNewRow event as follows:

 
private void gridView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            gridView.SetRowCellValue(e.RowHandle, viewAddColumns.Columns["colFieldName"], (((RepositoryItemComboBox)gridView.Columns["colFieldName"].ColumnEdit).Items[0]));
            
        }


You can also retrieve the value of the selectedindex of the RepositoryItemComboBox by handling SelectedIndexChanged event of the same. as:

((RepositoryItemComboBox)gridView.Columns["ColName"].ColumnEdit).SelectedIndexChanged += new System.EventHandler(ColName_SelectedIndexChanged);

in load event and defining event as follows

         private void ColName_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int i = ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedIndex;
        }

 

 

 
posted on 2012-08-18 11:22  forrestsun  阅读(2783)  评论(0编辑  收藏  举报