Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between System.Windows.Controls.Control and System.Windows.Forms.Control?

Tags:

c#

wpf

I'm confused, can anyone help me out?

Edit

My problem is that I have created an ActiveX control in Delphi and I just can't get it to play nicely in WPF land. I have looked at the relevant MSDN pages, and it looks like it SHOULD work, so I may have gone wrong in the way that I have created the ActiveX control in the first place.

See Hosting ActiveX control in WPF

like image 861
mmmm Avatar asked Jun 20 '10 23:06

mmmm


3 Answers

They are controls that live in completely different worlds.

System.Windows.Controls.Control is a WPF control.

System.Windows.Forms.Control is a WinForms control.

The choice is pretty simple. If you are developing a WinForms app - use WinForms controls. Similarly, if you are writing a WPF app - use WPF controls.

As for choosing between WPF and WinForms - this question might help.

like image 88
Igor Zevaka Avatar answered Nov 10 '22 16:11

Igor Zevaka


Have a look at the official documentation for both classes


Here is the Class signature for System.Windows.Controls.control class

public class Control : FrameworkElement

Here is the Class signature for System.Windows.Forms.Control class

public class Control : Component, IOleControl, 
    IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject, 
    IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage, 
    IQuickActivate, ISupportOleDropSource, IDropTarget, ISynchronizeInvoke, IWin32Window, 
    IArrangedElement, IBindableComponent, IComponent, IDisposable

like image 33
Asad Avatar answered Nov 10 '22 15:11

Asad


System.Windows.Controls.Control is for WPF application

System.Windows.Forms.Control i s for Winforms application.

like image 34
Johnny Avatar answered Nov 10 '22 15:11

Johnny