Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
  16.       int ARow, TRect &Rect, TGridDrawState State)
  17. {
  18.   if(ACol<1)return;
  19.   if(ARow==3)
  20.   {
  21.     StringGrid1->Canvas->Font->Size=12;
  22.     StringGrid1->Canvas->Font->Color=clBlack;
  23.     StringGrid1->Canvas->Font->Name="黑体";
  24.     StringGrid1->Canvas->Brush->Color=clRed;
  25.     StringGrid1->Canvas->Brush->Style=bsSolid;
  26.     StringGrid1->Canvas->Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
  27.     StringGrid1->Canvas->TextOut(Rect.Left+2,Rect.Top+2,StringGrid1->Cells[ACol][ARow]);
  28.   }
  29. }
  30. //---------------------------------------------------------------------------
  31. void __fastcall TForm1::Button1Click(TObject *Sender)
  32. {
  33.   StringGrid1->Cells[1][3]="北京";
  34.   StringGrid1->Cells[2][3]="上海";
  35.   StringGrid1->Cells[3][3]="深圳";
  36.   StringGrid1->Cells[4][3]="西安";
  37. }
  38. //---------------------------------------------------------------------------