您可以在GridViewComboBoxColumn的EditorInitialized事件中订阅下拉列表的SelectionChanged事件,并将处理程序添加到事件。这样,每当选择更改时,都会调用处理程序,而不会在滚动时触发事件。
以下是代码示例:
private void radGridView1_EditorInitialized(object sender, GridViewEditorEventArgs e)
{
if (e.Editor is RadDropDownListEditor)
{
RadDropDownListEditor editor = e.Editor as RadDropDownListEditor;
editor.DropDownStyle = RadDropDownStyle.DropDown;
RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
element.DropDownStyle = RadDropDownStyle.DropDown;
RadDropDownListEditorElement editorElement = editor.EditorElement as RadDropDownListEditorElement;
editorElement.DropDownListElement.SelectedIndexChanged += DropDownListElement_SelectedIndexChanged;
}
}
private void DropDownListElement_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
RadDropDownListEditorElement dd = (RadDropDownListEditorElement)sender;
GridViewRowInfo row = dd.Parent as GridViewRowInfo;
// 选择更改时的处理程序
}