2

I want to add ElementHost to my datagridview to bring the designed WPF control to the win form. My question is how to do this! This is my code so far:

            dgv.Columns[0].Name = "controls?";
            ElementHost host = new ElementHost();
            UserControl1 uc;
            uc = new UserControl1(10,20);
            host.Name = "test";
            host.Dock = DockStyle.Fill;
            host.Child = uc;
            dgv.Columns.Add(host); //< this gives me error!

I tried both dgv.Columns.Add(host) and dgv.Controls.Add(host) but they are not working. Is there anyway to do this? Thanks for the help.

p.s. datagridview should have 10 rows and each row has one usercontrol embedded in each cell.

Amir
  • 625
  • 1
  • 11
  • 26

0 Answers0