Copy Selected Text from a combobox to clipboard

-1

i got a little problem with my program...

I have a combobox with 4 variables and a button to copy the text in the combobox.

If i select the first one in the combobox and press the copy button the test ends and vs saýs:

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
c#
asked on Stack Overflow Sep 2, 2017 by M. Ivy

1 Answer

0

With just the exception text it is a little difficult to tell, but it sounds like you may be trying to copy a null or empty string to the clipboard. C# does not allow you to copy an empty string to the clipboard, and will throw this error.

answered on Stack Overflow Sep 2, 2017 by Andrew Jansen

User contributions licensed under CC BY-SA 3.0