DataGridView size is out of splitContainer panel even the Dock property is Fill

3.8k views Asked by At

There are a SplitContainer and couple of DataViewGrids. In Designer I docked DataViewGrids to Panel1 and Panel2 of SplitContainer respectively. So, in designer everithing seems to be OK. But when I start the program, the DataGridView seems like it's docked to the main form, because the size of the Grid is the main Form size. I use the Grids with bindings to DataSet. When I try to use not binded blanc Grids, everithing is ok. The grids size matches the splitContainer Panels sizes. That drives me insane:(

2

There are 2 answers

1
DeveloperX On

ok you should set dockstyle of grid to fill the panel as this

datagrid1.Dock=DockStyle.Fill;
0
moldov On

So I resolved, that problem. I put that code after all data bindings of dataGRidView

dataGridViewPO.Dock = DockStyle.Fill;
dataGridViewPO.Parent = splitContainer1.Panel1;