Click here to Skip to main content
15,895,799 members
Articles / Desktop Programming / ATL

Using MS DataGrid control with OLE DB consumer

Rate me:
Please Sign up or sign in to vote.
4.25/5 (8 votes)
22 Sep 20013 min read 189.7K   2.2K   37  
Use the MS DataGrid control in your C++ app with OLE DB Consumer Templates
//{{AFX_INCLUDES()
#include "datagrid.h"
//}}AFX_INCLUDES
#if !defined(AFX_DATAGRIDVIEW_H__73E2603C_98B0_40B4_8B8B_B0383E6A289C__INCLUDED_)
#define AFX_DATAGRIDVIEW_H__73E2603C_98B0_40B4_8B8B_B0383E6A289C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DataGridView.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CDataGridView form view

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif

class CDataGridView : public CFormView
{
protected:
	CDataGridView();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(CDataGridView)

// Form Data
public:
	//{{AFX_DATA(CDataGridView)
	enum { IDD = IDD_GRID_VIEW };
	CDataGrid	m_ctlDataGrid;
	//}}AFX_DATA

// Attributes
public:
    void UpdateGridDetails(const CString& sTableName);

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDataGridView)
	public:
	virtual void OnInitialUpdate();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CDataGridView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(CDataGridView)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnRecordsAllowdeleterecords();
	afx_msg void OnUpdateRecordsAllowdeleterecords(CCmdUI* pCmdUI);
	afx_msg void OnRecordsAlloweditrecords();
	afx_msg void OnUpdateRecordsAlloweditrecords(CCmdUI* pCmdUI);
	afx_msg void OnRecordsAllownewrecords();
	afx_msg void OnUpdateRecordsAllownewrecords(CCmdUI* pCmdUI);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

    bool m_bAllowNew;
    bool m_bAllowEdit;
    bool m_bAllowDelete;

    CString GetErrorDescription(_com_error& e);
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DATAGRIDVIEW_H__73E2603C_98B0_40B4_8B8B_B0383E6A289C__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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


Written By
Web Developer
United Kingdom United Kingdom
Was made redundant in early 2003 after 10 years in computer programming, since then started my own business (selling computer books on the net)
www.pricecutbook.co.uk


Comments and Discussions