标签:
原文链接地址:http://www.codeproject.com/Articles/8/MFC-Grid-control
MFCGridCtrl是个强大的类,用于数据的表格显示。
CGridCtrl grid;
grid.Create(rect, pParentWnd, nID);
int GetRowCount() const //Returns the number of rows (including fixed rows) int GetColumnCount() const //Returns the number of columns (including fixed columns) int GetFixedRowCount() const //Returns the number of fixed rows int GetFixedColumnCount() const //Returns the number of fixed columns BOOL SetRowCount(int nRows) //Sets the number of rows (including fixed rows), Returning TRUE on success. BOOL SetColumnCount(int nCols) //Sets the number of columns (including fixed columns), Returning TRUE on success. BOOL SetFixedRowCount(int nFixedRows = 1) //Sets the number of fixed rows, returning TRUE on success. BOOL SetFixedColumnCount(int nFixedCols = 1) //Sets the number of columns, returning TRUE on success.
int GetRowHeight(int nRow) const //Gets the height of row nRow. BOOL SetRowHeight(int row, int height) //Sets the height of row nRow. int GetColumnWidth(int nCol) const //Gets the width of column nCol BOOL SetColumnWidth(int col, int width) //Sets the width of column nCol. int GetFixedRowHeight() const //Gets the combined height of the fixed rows. int GetFixedColumnWidth() const //Gets the combined width of the fixed columns. long GetVirtualHeight() const //Gets the combined height of all the rows. long GetVirtualWidth() const //Gets the combined width of all the columns.
获取cell位置及矩形
BOOL GetCellOrigin(int nRow, int nCol, LPPOINT p); BOOL GetCellOrigin(const CCellID& cell, LPPOINT p); BOOL GetCellRect(int nRow, int nCol, LPRECT pRect); BOOL GetCellRect(const CCellID& cell, LPRECT pRect); BOOL GetTextRect(const CCellID& cell, LPRECT pRect); BOOL GetTextRect(int nRow, int nCol, LPRECT pRect); CSize GetTextExtent(int nRow, int nCol, LPCTSTR str); CSize GetCellTextExtent(int nRow, int nCol);
void Reorder(int From, int To); //Reorders a row ‘From‘ to row ‘To‘ void AllowReorderColumn(bool b=true) // Whether or not columns can be reordered void EnableDragRowMode(bool b=true) //Whether or not rows can be reordered via drag and drop int GetLayer(int** pLayer) // Returns a pointer to an array of ints representing the current ordering of the grid. Do not forget to delete *pLayer when you are finished void SetLayer(int* pLayer) //Sets the ordering of the grid based on a previous saved state.
void SetVirtualMode(BOOL bVirtual) //Places the grid in or out of virtual mode. BOOL GetVirtualMode() //Returns TRUE if the grid is in virtual mode
虚模式需要回调函数,如果不设置则会给父窗口发送GVN_GETDISPINFO通知消息
回调函数格式如下:
void SetCallbackFunc(GRIDCALLBACK pCallback, LPARAM lParam)
标签:
原文地址:http://www.cnblogs.com/wuyuan2011woaini/p/5737403.html