Those two useful classes are both under the System.Windows.Forms reference....
I can't see much relation between those and winforms.. Does anybody know why they're there?
thanks.
Those two useful classes are both under the System.Windows.Forms reference....
I can't see much relation between those and winforms.. Does anybody know why they're there?
thanks.
SendKeys can be handy for highlighting of textboxes. SendKeys "{HOME}+{END}" is a typical technique carried over from Visual Basic once a textbox has focus.
The Clipboard class is useful because it allows you to get data stored on a machine's clipboard, especially useful if it's data that comes from another application running. The clipboard is expected behavior in almost all applications that have any copy/paste semantic.
They internally use Win32 platform APIs, on which WinForm was built.
Windows Forms was, when it was made, the ONLY (Microsoft) means of creating a graphical user interface on the desktop.
SendKeys and the Clipboard are both using the Windows API in order to manipulate GUI applications. When this was created, it was reasonable to assume that these would be used from within a GUI program, which (then) meant a Windows Forms application.
Neither of these would typically be used from a Console application, but if you were doing so, including the "windowing" assemblies (which, at the time, meant windows forms) was a reasonable thing to do, since you're working with the Windowing system.
I do agree, though, that now that WPF exists, it would be nicer to have these in a separate assembly. However, Microsoft is very good about maintaining backwards compatibility.
To this end, they left this in the Windows Forms namespaces, but also implemented System.Windows.Clipboard for WPF applications. (I believe they decided that SendKeys was not required in modern development, since it's kind of abused, and just left it out by design.)
Generally speaking, you would not use Clipboard or SendKeys with an ASP.Net application or a console application, so it makes total sense for them to be in System.Windows.Forms
.
Where would you expect them to be? In System.ClipboardAndSendKeys
?