CGridCtrl复选框 居中
场景:如何让CGridCtrl复选框居中
怎么让CGridCtrl复选框居中
如图:
1、CGridCtrl里的复选框是靠左的,我想要它居中该怎么做。
2、复选框单元格时,不需要文字,且不可以编辑;但复选框的钩要,能勾上与取消。
------解决方案--------------------
我改了这个CGridCellCheck, 给我邮箱吧 , 给你发过去
实现你想要的所有功能
部分代码如下:
怎么让CGridCtrl复选框居中
如图:
1、CGridCtrl里的复选框是靠左的,我想要它居中该怎么做。
2、复选框单元格时,不需要文字,且不可以编辑;但复选框的钩要,能勾上与取消。
------解决方案--------------------
我改了这个CGridCellCheck, 给我邮箱吧 , 给你发过去
实现你想要的所有功能
部分代码如下:
- C/C++ code
void CGridCellCheck::OnClick(CPoint PointCellRelative) { // PointCellRelative is relative to the topleft of the cell. Convert to client coords PointCellRelative += m_Rect.TopLeft(); // Bail if cell is read-only CCellID cell = GetGrid()->GetCellFromPt(PointCellRelative); //change by jg if (!GetGrid()->IsEditable()) { return; } else { if (!m_bEditable) { return; } } //end // GetCheckPlacement returns the checkbox dimensions in client coords. Only check/ // uncheck if the user clicked in the box if (GetCheckPlacement().PtInRect(PointCellRelative)) { m_bChecked = !m_bChecked; GetGrid()->InvalidateRect(m_Rect); } } ////////////////////////////////////////////////////////////////////// // Operations ////////////////////////////////////////////////////////////////////// BOOL CGridCellCheck::SetCheck(BOOL bChecked /*=TRUE*/) { BOOL bTemp = m_bChecked; m_bChecked = bChecked; if (!m_Rect.IsRectEmpty()) GetGrid()->InvalidateRect(m_Rect); return bTemp; } BOOL CGridCellCheck::GetCheck() { return m_bChecked; }