I have created an MFC grid control (Code Project MFC Grid control 2.27) in an MFC dialog MyDlg (C++, VS2015, 64-bit Windows 7). The MyDlg.h file contains
CGridCtrl gridCtrl;
and the resource editor was used to add a custom control of type MFCGridCtrl. In MyDlg.cpp, I am subclassing the control with
DDX_Control(pDX, IDC_ComponentRatios, gridCtrl);
In MyDlg::OnInitDialog, I set the number of rows and columns with
gridCtrl.SetColumnCount(2);
gridCtrl.SetRowCount(2);
gridCtrl.EnableWindow(TRUE);
What I get is the 2 x 2 grid I expect, but the size of the custom control does not match the size of the grid.
The custom control's width is wrong, because setting the column count appears to be leaving space for a scroll bar, which is unnecessary.
The height is unchanged, which is wrong because the custom control is sized for 8 rows, and I'm only using 2 in this example (the actual number of rows required is variable).
How can I get the grid to fill the width of the custom control, and to resize the height of that control to match?