StringGrid合并单元格
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";}
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后所有的效果都要自己手动画