Microsoft DataGrid Control 
Author Message
 Microsoft DataGrid Control

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.


Fri, 01 Mar 2002 03:00:00 GMT  
 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:
}



Fri, 01 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ??? Problems in Microsoft Datagrid Control Version 6.0 ????

2. Adding Columns and Rows in Microsoft Datagrid Control 6.0

3. Help using Microsoft DataGrid Control 6.0 (SP4) (OLEDB)

4. Problems in Microsoft Datagrid Control Version 6.0 ??????????

5. How to use Microsoft Datagrid Control without binding with ADO?

6. Join the effort -- Microsoft DataGrid FAQ

7. Microsoft DataGrid FAQ -- searching for maintainer (0.5, 19th June 2001)

8. Join the effort -- Microsoft DataGrid FAQ

9. Join the effort -- Microsoft DataGrid FAQ

10. Join the effort -- Microsoft DataGrid FAQ (repost)

11. Microsoft DataGrid FAQ -- join the effort

12. Using Microsoft DataGrid

 

 
Powered by phpBB® Forum Software