0

我将按钮的“启用”属性绑定到数据源成员。我使用Infragistics.Win.Misc.UltraButton控制及其方法DataBindings.Add( System.Windows.Forms.Binding )。该按钮位于对话框形式上。当我第一次打开对话框时,绑定就添加好了。在我关闭对话框并第二次打开它后,我得到异常System.Windows.Forms.ControlBindingsCollection.Add(Binding binding),消息说按钮的“启用”属性是只读的。如何解决这个问题?

对话框打开代码是这样的:

using (PickItemDialog dialog = new PickItemDialog())
{
    dialog.ViewModel = new PickItemViewModel();
    dialog.ViewModel.Items = new BindingList<T>(records.ToList());
    dialog.ViewModel.Title = title;
    dialog.ViewModel.Notification = notification;
    if (dialog.ShowDialog() == DialogResult.OK)
        return (DataItem)dialog.ViewModel.SelectedItem;
}
4

0 回答 0