📄 gridctrl.shtml
字号:
takes a copy of the pointer to the image list, not a copy of the list itself.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">CImageList* GetImageList()</FONT></PRE>
</TD><TD WIDTH="50%">Gets the current image list for the grid.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetGridLines(int nWhichLines = GVL_BOTH)</FONT></PRE>
</TD><TD WIDTH="50%">Sets which (if any) gridlines are displayed.
See <a href="GridCtrl.shtml#GVL_Values">here</a> for possible values.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">int GetGridLines() </FONT></PRE>
</TD><TD WIDTH="50%">Gets which (if any) gridlines are displayed.
See <a href="GridCtrl.shtml#GVL_Values">here</a> for possible return values.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetEditable(BOOL bEditable = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets if the geid is editable.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL IsEditable()</FONT></PRE>
</TD><TD WIDTH="50%">Gets whether or not the grid is editable.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetModified(BOOL bModified = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the modified flag for the grid.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetModified()</FONT></PRE>
</TD><TD WIDTH="50%">Sets the modified flag for the grid.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetListMode(BOOL bEnableListMode = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the grid into (or out of) List mode. When the grid is in list mode,
full row selection is enabled and clicking on the column header will sort the grid by rows.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetListMode()</FONT></PRE>
</TD><TD WIDTH="50%">Get whether or not the grid is in list mode.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void EnableSelection(BOOL bEnable = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets whether or not the grid cells can be selected.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL IsSelectable()</FONT></PRE>
</TD><TD WIDTH="50%">Get whether or not grid cells are selectable.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void EnableDragAndDrop(BOOL bAllow = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets whether drag and drop is enabled.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetDragAndDrop()</FONT></PRE>
</TD><TD WIDTH="50%">Get whether drag and drop is allowed.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetRowResize(BOOL bResize = TRUE) </FONT></PRE>
</TD><TD WIDTH="50%">Sets whether or not rows can be resized.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetRowResize()</FONT></PRE>
</TD><TD WIDTH="50%">Gets whether or not rows can be resized.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetColumnResize(BOOL bResize = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets whether or not columns can be resized.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetColumnResize()</FONT></PRE>
</TD><TD WIDTH="50%">Gets whether or not columns can be resized.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetHeaderSort(BOOL bSortOnClick = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets whether or not rows are sorted on column header clicks in ListMode.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetHeaderSort()</FONT></PRE>
</TD><TD WIDTH="50%">Gets whether or not rows are sorted on column header clicks in ListMode.</TD>
</TR>
</table>
<h3><a name="Colours">Colours</a></h3>
<TABLE CELLSPACING=0 WIDTH="90%">
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetTextColor(COLORREF clr)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the colour of the text in non-fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">COLORREF GetTextColor()</FONT></PRE>
</TD><TD WIDTH="50%">Gets the colour of the text in non-fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetTextBkColor(COLORREF clr)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the background colour of the non-fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">COLORREF GetTextBkColor() </FONT></PRE>
</TD><TD WIDTH="50%">Gets the background colour of the non-fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetFixedTextColor(COLORREF clr)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the colour of the text in fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">COLORREF GetFixedTextColor()</FONT></PRE>
</TD><TD WIDTH="50%">Gets the colour of the text in fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetFixedBkColor(COLORREF clr)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the background colour of the fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">COLORREF GetFixedBkColor() </FONT></PRE>
</TD><TD WIDTH="50%">Gets the background colour of the fixed cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetBkColor(COLORREF clr)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the background colour of the control
(the area outside fixed and non-fixed cells).</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">COLORREF GetBkColor() </FONT></PRE>
</TD><TD WIDTH="50%">Gets the background colour of the control.</TD>
</TR>
</Table>
<h3><a name="CellInfo">General cell information</a></h3>
<TABLE CELLSPACING=0 WIDTH="90%">
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">int GetSelectedCount()</FONT></PRE>
</TD><TD WIDTH="50%">Gets the number of selected cells.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">CCellID GetFocusCell()</FONT></PRE>
</TD><TD WIDTH="50%">Gets the cell with the focus.
See also <a href="GridCtrl.shtml#CCellID">CCellID<a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL SetItem(const GV_ITEM* pItem)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the contents of a cell with the values from the
<a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a> structure. Note that the value
of the mask field will determine which values are actually changed
(cf. CListCtrl::SetItem).
</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetItem(GV_ITEM* pItem)</FONT></PRE>
</TD><TD WIDTH="50%">Fills the <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>
structure with values from the specified cell. Note that the value of the
mask field will determine which values are actually retrieved
(cf. CListCtrl::GetItem). </TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL SetItemText(int nRow, int nCol, LPCTSTR str)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the text for the given cell. Returns TRUE on success</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">virtual CString GetItemText(int nRow, int nCol)</FONT></PRE>
</TD><TD WIDTH="50%">Gets the text for the given cell. This function is virtual
in order to aid extensibility. No more messing around with LVN_GETDISPINFO messages or
string pooling!</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL SetItemData(int nRow, int nCol, LPARAM lParam)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the lParam (user-defined data) field for the given cell.
Returns TRUE on success. See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">LPARAM GetItemData(int nRow, int nCol) const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the lParam (user-defined data) field for the given cell.
See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL SetItemImage(int nRow, int nCol, int iImage)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the image index for the given cell. Returns TRUE on success.
See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">int GetItemImage(int nRow, int nCol) const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the image index for the given cell.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL SetItemState(int nRow, int nCol, UINT state)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the state of the given cell. Returns TRUE on success.
See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">UINT GetItemState(int nRow, int nCol) const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the state of the given cell.
See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL SetItemFormat(int nRow, int nCol, UINT nFormat)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the format of the given cell. Returns TRUE on success. Default
implementation of cell drawing uses CDC::DrawText, so any of the DT_* formats are available.
See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">UINT GetItemFormat(int nRow, int nCol) const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the format of the given cell (default returns a CDC::DrawText DT_* format).
See also <a href="GridCtrl.shtml#GV_ITEM">GV_ITEM</a>.</TD>
</TR>
</table>
<h3><a name="Operations">Operations</a></h3>
<TABLE CELLSPACING=0 WIDTH="90%">
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">int InsertColumn(LPCTSTR strHeading,
UINT nFormat, int nColumn = -1)</FONT></PRE>
</TD><TD WIDTH="50%">Inserts a column at the position given by nCol, or at
the end of all columns if nCol is < 0. <b>strHeading</b> is the column heading
and <b>nFormat</b> the format. Returns the position of the inserted column.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">int InsertRow(LPCTSTR strHeading, int nRow = -1)</FONT></PRE>
</TD><TD WIDTH="50%">Inserts a row at the position given by nRow, or at
the end of all rows if nRow is < 0. <b>strHeading</b> is the row heading.
The format of each cell in the row will be that of the cell in the first
row of the same column. Returns the position of the inserted row.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL DeleteColumn(int nColumn)</FONT></PRE>
</TD><TD WIDTH="50%">Deletes column "nColumn", return TRUE on success.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL DeleteRow(int nRow)</FONT></PRE>
</TD><TD WIDTH="50%">Deletes row "nRow", return TRUE on success.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void DeleteAllItems()</FONT></PRE>
</TD><TD WIDTH="50%">Deletes all rows and contents in the grid.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL AutoSizeRow(int nRow)</FONT></PRE>
</TD><TD WIDTH="50%">Auto sizes the row to the size of the largest item.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL AutoSizeColumn(int nCol)</FONT></PRE>
</TD><TD WIDTH="50%">Auto sizes the column to the size of the largest item.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void AutoSizeRows()</FONT></PRE>
</TD><TD WIDTH="50%">Auto sizes all rows.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void AutoSizeColumns()</FONT></PRE>
</TD><TD WIDTH="50%">Auto sizes all columns.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void AutoSize()</FONT></PRE>
</TD><TD WIDTH="50%">Auto sizes all rows and columns.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void ExpandColumnsToFit()</FONT></PRE>
</TD><TD WIDTH="50%">Expands the column widths to fit the grid area.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void ExpandRowsToFit()</FONT></PRE>
</TD><TD WIDTH="50%">Expands the row heights to fit the grid area.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void ExpandToFit()</FONT></PRE>
</TD><TD WIDTH="50%">Expands the rows and columns to fit the grid area.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetRedraw(BOOL bAllowDraw,
BOOL bResetScrollBars = FALSE)</FONT></PRE>
</TD><TD WIDTH="50%">Stops/starts redraws on things like changing the number of
rows and columns and autosizing, but not for user-intervention such as resizes.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL RedrawCell(int nRow, int nCol, CDC* pDC = NULL)</FONT></PRE>
</TD><TD WIDTH="50%">Redraws the given cell. Drawing will be via the pDC
if one is supplied.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL RedrawCell(const CCellID& cell, CDC* pDC = NULL)</FONT></PRE>
</TD><TD WIDTH="50%">Redraws the given cell. Drawing will be via the pDC
if one is supplied.</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL RedrawRow(int row)</FONT></PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -