Articles in this section
Category / Section

How to host the Spreadsheet control of WPF in Windows Forms?

1 min read

Host WPF spreadsheet in WF


In order to host the Spreadsheet control of WPF in Windows Forms, make use of the ElementHost Container. This support is provided by Microsoft for hosting WPF controls in a Windows Forms application.

For more details, please refer to this link: Hosting WPF control in WinForms


ElementHost elhost = new ElementHost();
elhost.Size = new System.Drawing.Size(1000, 600);
Spreadsheet wpfctl = new Spreadsheet();
elhost.Child = wpfctl;
this.Controls.Add(elhost);
Dim elhost As New ElementHost()
elhost.Size = New System.Drawing.Size(1000, 600)
Dim wpfctl As New Spreadsheet()
elhost.Child = wpfctl
Me.Controls.Add(elhost)

The output is as follows:

Added WPF spreadsheet control in Windows Forms


Samples:

C#: Hosting_WPF_controls_in_WinForms_CS

VB: Hosting_WPF_controls_in_WinForms_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied