7

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

Community
  • 1
  • 1
mmmm
  • 2,431
  • 2
  • 35
  • 56

6 Answers6

18

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.

Community
  • 1
  • 1
Igor Zevaka
  • 74,528
  • 26
  • 112
  • 128
5

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

Asad
  • 21,468
  • 17
  • 69
  • 94
1

System.Windows.Controls.Control is for WPF application

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

Johnny
  • 1,555
  • 3
  • 14
  • 23
0

System.Windows.Forms.Control
Defines the base class for controls, which are components with visual representation.

System.Windows.Controls.Control
Represents the base class for user interface (UI) elements that use a ControlTemplate to define their appearance.

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
0

What is Windows Presentation Foundation and Windows Forms?

You should be able to determine that from the namespace that one is the base Control class for WPF (all WPF uses the .Windows naming) and the other is for Windows Forms.

Can you clarify what exactly you find confusing? I will update my answer.

HTH,

Useful links
- Windows Forms Controls and Equivalent WPF Controls
- System.Windows.Forms
- System.Windows.Controls

Dennis
  • 20,275
  • 4
  • 64
  • 80
  • What I find confusing is probably the import of the ActiveX control. It is written in Delphi, and obviously doesn't descend from System.Windows.Forms.Control. – mmmm Jun 21 '10 at 20:50
0

I think there are a number of differences but the first one that jumps to mind is that System.Windows.Controls.Control uses a template to define the visual aspects of the control, without a template it has no visual aspect at all. In other words without defining that template you cannot focus it to become visible or show it in your application, because there is literally no visual definition for it.

On the other hand you have a System.Windows.Forms.Control which allows you to create a control that inherits from a UserControl, control class, or other Windows Control. If you don't specify a new visual setting for your control it will display according to what the parent control you inherited from was set to display.

So, with System.Windows.Controls.Control you get a lot more flexibility as the cost of additional work, and with System.Windows.Forms.Control you get to inherit from existing controls, saving time, as the cost of less flexibility.

Tim C
  • 1,934
  • 12
  • 25
  • Hi Tim, please see Igor's answer, as your is way off. – CodeNaked Jun 21 '10 at 19:05
  • I am not sure where you are coming from with this comment that I am "way off". Granted Forms.Control is for Windows forms, and Controls.Control is for WPF, but the original, pre-edit question just asked for the difference, and this is one of the major differences, as pointed out in these MSDN articles: http://msdn.microsoft.com/en-us/library/system.windows.controls.control.aspx and http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx. I would love to know how that is off? – Tim C Jun 21 '10 at 21:54
  • 1
    Your answer implies that the two are interchangable, based on whether you want more flexibility or less work, which they are not. – CodeNaked Jun 27 '10 at 23:59