首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

StringGrid合并单元格解决方法

2012-03-20 
StringGrid合并单元格C/C++ codevoid __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol

StringGrid合并单元格

C/C++ code
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,      int ARow, TRect &Rect, TGridDrawState State){    if (ACol == 0)    {        if ( (ARow == 1) || (ARow == 3))            Rect.Bottom = Rect.Bottom + Rect.Height();        if ( (ARow == 2) || (ARow == 4))            Rect.Top = Rect.Bottom;    }    StringGrid1->Canvas->FillRect(Rect);    DrawText(StringGrid1->Canvas->Handle, StringGrid1->Cells[ARow][ACol].c_str(),        StringGrid1->Cells[ARow][ACol].Length() , &Rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);}void __fastcall TForm1::btn1Click(TObject *Sender){    StringGrid1->Cells[1][0] = "1";    StringGrid1->Cells[1][1] = "2";    StringGrid1->Cells[2][1] = "3";    StringGrid1->Cells[3][0] = "4";    StringGrid1->Cells[3][1] = "5";    StringGrid1->Cells[4][1] = "6";}


我把StringGrid的DefaultDrawing 改成false
然后点那个Button1 可是单元格内容不能显示,只有点了相应单元格 才会显示 或者把窗体切换下,怎么回事 要怎么改呢

[解决办法]
C/C++ code
void __fastcall TForm1::Button1Click(TObject *Sender){ StringGrid1->Cells[1][0] = "1";    StringGrid1->Cells[1][1] = "2";    StringGrid1->Cells[2][1] = "3";    StringGrid1->Cells[3][0] = "4";    StringGrid1->Cells[3][1] = "5";    StringGrid1->Cells[4][1] = "6";    StringGrid1->Invalidate();}
[解决办法]
defaultdrawing设为false后所有的效果都要自己手动画

热点排行