谁用过GridCtrl?

来源:百度知道 编辑:UC知道 时间:2024/05/14 12:15:07
把字体设成粗体怎么设啊?

CFont font;
VERIFY(font.CreateFont(
14, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial"))); // lpszFacename

// Do something with the font just created...
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&font);
m_pGridCtrl->SetFont(&font);
dc.SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();

把代码粘贴到你的工程里,ctrl+a,alt+f8自动缩进看吧。m_pGridCtrl是你的CGridCtrl对象指针。
ps:此代码于vs2008环境下测试通过。估计vs2005下unicode码下也没问题。如果是vc6非unicode码,_T("Arial")改为"Arial"应该能解决问题,或者参考下msdn,自己建立个字体对象,然后m_pGridCtrl->SetFon