Microsoft DataGrid Control
Quote:
> I have found no way of modifying the column headers of the datagrid
> control. I have looked at the CColumn, CDataGrid and CColumns (As well
> as the MSDN Library). Can somebody give me an idea ? Many Thanks.
I used the following code in the OnInitialUpdate() member function of my
view class to modify the column headings of a Data Grid on my CFormView
dialog. I'm new to VC++ so someone else might be able to give you a
better solution - but this will get the job done. Hope this helps....
void CCashRegisterView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
// Set the DataGrid Column Names
CColumn colTemp;
for (int i=0; i<6; i++)
{
// Get the current column
_variant_t vCol((long)i);
colTemp = m_adoDataGrid_TempTran.GetColumns().GetItem(vCol);
// Set column widths and header text
colTemp.SetWidth(72);
switch (i)
{
case 0:
colTemp.SetCaption("Type");
break;
case 1:
colTemp.SetCaption("Barcode");
break;
case 2:
colTemp.SetCaption("Date");
break;
case 3:
colTemp.SetCaption("Price");
break;
case 4:
colTemp.SetCaption("Qty");
break;
case 5:
colTemp.SetCaption("Tax");
break;
}
}
Quote:
}