http://docwiki.embarcadero.com/CodeExamples/XE7/en/GridLineWidth_%28C%2B%2B%29

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  if (DrawGrid1->DefaultColWidth > 90)
    DrawGrid1->GridLineWidth = 2;
  else
    DrawGrid1->GridLineWidth = 1;
}
 
void __fastcall TForm1::DrawGrid1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect,
          TGridDrawState State)
{
  int index = ARow * DrawGrid1->ColCount + ACol;
  DrawGrid1->Canvas->Brush->Color = clBackground;
  DrawGrid1->Canvas->FillRect(Rect);
  ImageList1->Draw(DrawGrid1->Canvas, Rect.Left, Rect.Top, index, True);
  if (State.Contains(gdFocused))
  {
    DrawGrid1->Canvas->DrawFocusRect(Rect);
  }
}
 
void __fastcall TForm1::DrawGrid1SelectCell(TObject *Sender, int ACol, int ARow, bool &CanSelect)
 
{
  CanSelect = True;
}

 

posted on 2015-03-16 20:42  lypzxy  阅读(490)  评论(0编辑  收藏  举报