-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); } –