Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Date Time Picker control for the MFC Grid Control

0.00/5 (No votes)
30 May 2001 1  
A DateTime control for editing date or time values inplace in the MFC Grid Control

Sample Image - GridCellDateTime.gif

Introduction

This is a simple drop-in cell class for Chris Maunder's MFC Grid Control. The cell's class is CGridCellDateTime and is used in exactly the same way as other grid cell types.

The edit window that is created when the cell goes into edit mode is of type CDateTimeCtrl (so you need at least IE3 installed on your system for it to run)

Possible usage

MyDialog::OnInitDialog()
{
    ...  
    m_Grid.SetRowCount(44);
    m_Grid.SetColumnCount(22);
    m_Grid.SetFixedRowCount();

    for (int i =1; i <44; i++) 
    {
       m_Grid.SetCellType(i, 0, RUNTIME_CLASS(CGridCellDateTime));
       ((CGridCellDateTime*) m_Grid.GetCell(i, 0))->Init(DTS_SHORTDATEFORMAT);

       m_Grid.SetCellType(i, 1, RUNTIME_CLASS(CGridCellDateTime));
       ((CGridCellDateTime*) m_Grid.GetCell(i, 1))->Init(DTS_TIMEFORMAT);
    }
    ...
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here