gridview组合框中的SelectedItem

时间:2013-04-27 07:04:25

标签: winforms telerik-grid radgridview radcombobox

我已经在RadGridView中填充了数据库中的组合框,我希望当它处于添加模式时,我的组合框会将其第一项显示为默认值。我使用了以下代码,但我在代码

中注释了注释行时出错了
      private void radGridView_CellValueChanged(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
        {

                    if (e.Column.Name == "Productcolumn")
                {
//ERROR on debuging following line
                    RadDropDownListEditor ed = this.radGridView.Columns["UnitPrice"] as RadDropDownListEditor;
                    if (ed != null)
                    {
                        // the default selected Price that will be shown will be the first price, if no price is selected for the current cell
                        RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)ed.EditorElement;
                        editorElement.SelectedIndex = 0;
                    }
    }
    }

0 个答案:

没有答案