-1
我有一个小问题,我的计划......从ComboBox将选定文本复制到剪贴板
我有4个变量和一个按钮的组合框的文本在ComboBox复制。
如果我选择在组合框中 的第一个,按复印键测试结束和VS说:
System.ArgumentNullException ist aufgetreten.
HResult=0x80004003
Nachricht = Der Wert darf nicht NULL sein.
Parametername: text
Quelle = System.Windows.Forms
Stapelüberwachung:
bei System.Windows.Forms.Clipboard.SetText(String text, TextDataFormat format)
bei System.Windows.Forms.Clipboard.SetText(String text)
bei WindowsFormsApp1.Form1.button2_Click(Object sender, EventArgs e) in
C:\Users\user\source\repos\WindowsFormsApp1\WindowsFormsApp1\Form1.cs: Zeile34
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.
System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.
FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei WindowsFormsApp1.Program.Main() in C:\Users\user\source\repos\WindowsFormsApp1\WindowsFormsApp1\Program.cs: Zeile19
请提供您的'WindowsFormsApp1.Form1.button2_Click'方法的代码。 –
我可怜的德语足以解决问题。你读过例外吗? 'Nachricht = Der Wert darf nicht NULL sein.' –
private void button2_Click(object sender,EventArgs e) { Clipboard.SetText(comboBox1.SelectedText); } –