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 Spreadsheet control of WPF in Windows Forms, make use ElementHost Container. This support is provided by Microsoft for hosting WPF controls in windows forms application. For more details, please refer this link: Hosting WPF control in WinForms

C#

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

 

VB

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)

 

Screenshot

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 sign in to leave a comment
Access denied
Access denied