StringGrid에서 마우스 올라가있는 cell만 색깔 바꾸기
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// 전역변수들입니다.. 초기화하는 중이구요 ^^
// 전 클래스 멤버 변수로 했슴다...
preCol = -1; preRow = -1; iCol = -1; iRow = -1;
}
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
// 이 이벤트는 해당 셀마다 각기 한번씩 들어 옵니다..
// 그래서 각기 셀마다 여기서 원하는 작업을 하실 수 있지요 ^^
if (iCol == ACol && iRow == ARow)
{
StringGrid1->Canvas->Brush->Color = clRed;
StringGrid1->Canvas->FillRect(Rect);
}
}
void __fastcall TForm1::StringGrid1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
StringGrid1->MouseToCell(X, Y, iCol, iRow);
if (preCol != iCol || preRow != iRow)
{
// Repaint를 해야 OnDrawCell 이 발생합니다....
StringGrid1->Repaint();
preCol = iCol;
preRow = iRow;
}