📄 gridctrl.shtml
字号:
</TD><TD WIDTH="50%">Gets the combined height of the fixed rows.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">int GetFixedColumnWidth() const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the combined width of the fixed columns.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">long GetVirtualHeight() const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the combined height of all the rows.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">long GetVirtualWidth() const</FONT></PRE>
</TD><TD WIDTH="50%">Gets the combined width of all the columns.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetCellOrigin(int nRow, int nCol, LPPOINT p)<br></FONT></PRE>
</TD><TD WIDTH="50%">Gets the topleft point for cell (nRow,nCol), returning
TRUE if successful. (cell must be visible for success).</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetCellOrigin(const CCellID& cell, LPPOINT p)<br></FONT></PRE>
</TD><TD WIDTH="50%">Gets the topleft point for the given cell, returning
TRUE if successful. (cell must be visible for success).
See also <a href="gridctrl.shtml#CCellID">CCellID<a>.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetCellRect(int nRow, int nCol, LPRECT pRect)</FONT></PRE>
</TD><TD WIDTH="50%">Gets the bounding rectangle for the given cell, returning
TRUE if successful. (cell must be visible for success).</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetCellRect(const CCellID& cell, LPRECT pRect)</FONT></PRE>
</TD><TD WIDTH="50%">Gets the bounding rectangle for the given cell, returning
TRUE if successful. (cell must be visible for success).
See also <a href="gridctrl.shtml#CCellID">CCellID<a>.</TD>
</TR>
</TABLE>
<h3><a name="Appearance">General appearance and features</a></h3>
<TABLE CELLSPACING=0 WIDTH="90%">
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetImageList(CImageList* pList)</FONT></PRE>
</TD><TD WIDTH="50%">Sets the current image list for the grid. The control only
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>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetHandleTabKey(BOOL bHandleTab = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets whether or not the TAB key is used to move the cell selection.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetHandleTabKey()</FONT></PRE>
</TD><TD WIDTH="50%">Gets whether or not the TAB key is used to move the cell selection.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">void SetDoubleBuffering(BOOL bBuffer = TRUE)</FONT></PRE>
</TD><TD WIDTH="50%">Sets whether or not double buffering is used when painting (avoids flicker).</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">BOOL GetDoubleBuffering()</FONT></PRE>
</TD><TD WIDTH="50%">Gets whether or not double buffering is used when painting.</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>
<p>See also the <a href="gridctrl.shtml#CellColours">Individual Cell colour
functions</a> that allow an individual cell's colours to be changes seperate
to the rest of the grid.
<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%">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -