Winforms 数据绑定在列表中找不到适用于使用组中超过9的RadioButton组的所有绑定的行

Winforms 数据绑定在列表中找不到适用于使用组中超过9的RadioButton组的所有绑定的行,winforms,radio-group,Winforms,Radio Group,我正在使用所描述的技术将我的单选按钮组添加到我的C#winforms应用程序中 public int PrinterTypeNum { get; set; } 在我尝试一个标签大于9的单选按钮之前,这项技术工作得很好 public int PrinterTypeNum { get; set; } 在这种情况下,单击单选按钮时发生错误 public int PrinterTypeNum { get; set; } System.InvalidOperationException未处理HRes

我正在使用所描述的技术将我的单选按钮组添加到我的C#winforms应用程序中

public int PrinterTypeNum { get; set; }
在我尝试一个标签大于9的单选按钮之前,这项技术工作得很好

public int PrinterTypeNum { get; set; }
在这种情况下,单击单选按钮时发生错误

public int PrinterTypeNum { get; set; }
System.InvalidOperationException未处理HResult=-2146233079
Message=DataBinding在列表中找不到适合的行 所有绑定。Source=系统堆栈跟踪: 位于System.ComponentModel.ReflectPropertyDescriptor.SetValue(对象 组件(对象值) 位于System.Windows.Forms.BindToObject.SetValue(对象值) 位于System.Windows.Forms.Binding.PullData(布尔格式,布尔强制) 在System.Windows.Forms.Binding.Target\u PropertyChanged(对象发送方,事件参数e) 在System.EventHandler.Invoke(对象发送方,EventArgs e) 在SBD.VivSnap.UI.RadioGroupBox.radioButton_CheckedChanged(对象发送器, 事件参数(e)在 e:\EShared\devnet10\VivSnap\SnapInUI\RadioGroupBox.cs:第70行 在System.EventHandler.Invoke(对象发送方,EventArgs e) 在System.Windows.Forms.RadioButton.OnClick(EventArgs e)中 在System.Windows.Forms.RadioButton.OnMouseUp(MouseEventArgs-mevent)上 在System.Windows.Forms.Control.WmMouseUp(Message&m、MouseButtons按钮、Int32单击) 位于System.Windows.Forms.Control.WndProc(Message&m) 位于System.Windows.Forms.ButtonBase.WndProc(Message&m) 在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd、Int32 msg、IntPtr wparam、IntPtr lparam) 在System.Windows.Forms.UnsafentiveMethods.DispatchMessageW(MSG&MSG)中 在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafentiveMethods.IMsoComponentManager.FPushMessageLoop(IntPtr)中 dwComponentID、Int32原因、Int32数据) 位于System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 原因(应用程序上下文上下文) 位于System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 原因(应用程序上下文上下文) 位于System.Windows.Forms.Form.ShowDialog(iwin32窗口所有者) 在SBD.VivSnap.Main.Form1.btnForm1Go_中,单击e:\EShared\devnet10\VivSnap\Main\Form1.cs中的(对象发送方,事件参数e):第36行 在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs-mevent)上 在System.Windows.Forms.Control.WmMouseUp(Message&m、MouseButtons按钮、Int32单击) 位于System.Windows.Forms.Control.WndProc(Message&m) 位于System.Windows.Forms.ButtonBase.WndProc(Message&m) 在System.Windows.Forms.Button.WndProc(Message&m)中 在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd、Int32 msg、IntPtr wparam、IntPtr lparam) 在System.Windows.Forms.UnsafentiveMethods.DispatchMessageW(MSG&MSG)中 在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafentiveMethods.IMsoComponentManager.FPushMessageLoop(IntPtr)中 dwComponentID、Int32原因、Int32数据) 位于System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 原因(应用程序上下文上下文) 位于System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 原因(应用程序上下文上下文) 在e:\EShared\devnet10\VivSnap\Main\Program.cs中的SBD.VivSnap.Main.Program.Main()处:第18行 位于System.AppDomain.\u nExecuteAssembly(RuntimeAssembly程序集,字符串[]args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()上 位于System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext、ContextCallback回调、对象状态、布尔值 (同步CTX) 在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态,布尔值 (同步CTX) 在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态) 位于System.Threading.ThreadHelper.ThreadStart()的内部异常:

public int PrinterTypeNum { get; set; }
我绑定属性的代码是

groupBox.DataBindings.Add("Selected", dataSource, PrinterTypeNum, false, DataSourceUpdateMode.OnPropertyChanged);
public int PrinterTypeNum { get; set; }
我的财产代码是

public int PrinterTypeNum  
{
    get
    {
        try
        {
            return (int)this.PrinterType;
        }
        catch (Exception)
        {
            return 0;
        }
    }
    set
    {
        try
        {
            this.PrinterType = (jtVivPrinterEnum)value;
            // the enum goes from 0 to 15
        }
        catch (Exception)
        {
            this.PrinterType = jtVivPrinterEnum.jtVivPrinterUnknown;
            throw;
        }
    }
}

public jtVivPrinterEnum PrinterType { get; set; }
public int PrinterTypeNum { get; set; }
**

public int PrinterTypeNum { get; set; }
[更新]我刚刚发现,如果属性如下所示,我不会得到错误

public int PrinterTypeNum { get; set; }
我的广播组课程如下 //

public int PrinterTypeNum { get; set; }
公共部分类RadioGroupBox:GroupBox
{
公共放射分组框()
{
this.InitializeComponent();
}
公共事件事件处理程序SelectedChanged=委托{};
int_选定;
已选择公共整数
{
得到
{
返回此项。\u选中;
}
设置
{
int-val=0;
var radioButton=this.Controls.OfType()
.FirstOrDefault(radio=>radio.Tag!=null
&&int.TryParse(radio.Tag.ToString(),out val)&&val==value);
如果(单选按钮!=null)
{
尝试
{
radioButton.Checked=true;
此项。_selected=val;
}
捕获(例外情况除外)
{
Print(例如ToString());
投掷;
}
}
}
}
已添加受保护的覆盖无效OnControlAdded(ControlEventArgs e)
{
添加的碱基(e);
var radioButton=e.控制为radioButton;
如果(单选按钮!=null)
radioButton.CheckedChanged+=此.radioButton\u CheckedChanged;
}
无效radioButton_CheckedChanged(对象发送方,事件参数e)
{
var单选=(RadioButton)发送器;
int-val=0;
if(radio.Checked&&radio.Tag!=null
&&int.TryParse(radio.Tag.ToString(),out val))
{
此项。_selected=val;
this.SelectedChanged(this,new EventArgs());//当v