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
Samples:
C#: Hosting_WPF_controls_in_WinForms_CS
VB: Hosting_WPF_controls_in_WinForms_VB