I have code similar to:
public datagridview dg = new datagridview();
//populate grid.
Fo开发者_StackOverflow中文版rm1 GUI = new Form1();
_dgv.Location = new System.Drawing.Point(0, 50);
_dgv.Size = new System.Drawing.Size(630, 200);
GUI.splitContainer1.Panel2.Controls.Add(_dgv);
This I was hoping, would place the datagridview on the GUI WinForm, but nothing shows up.
Any ideas?
Have you made sure the splitContainer1 is appropriately placed and sized? If it's too small, perhaps the DataGridView is located outside it's container (splitContainer1).
Set the parent of the dgv to be the panel:
Form1 GUI = new Form1();
_dgv.Parent = GUI.splitContainer1.Panel2;
_dgv.Location = new System.Drawing.Point(0, 50);
_dgv.Size = new System.Drawing.Size(630, 200);
I know this theoretically does the same thing, but it works for me
精彩评论