DataEdit.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:3k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "DataEdit.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. TBookmark SavePlace;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::FormCreate(TObject *Sender)
  17. {
  18. Form1->Timer1->Enabled=true;
  19. //设置控件的有效状态
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::Button1Click(TObject *Sender)
  23. {
  24. Form1->Table1->First();
  25. //移动到第一条记录
  26. }
  27. //---------------------------------------------------------------------------
  28. void __fastcall TForm1::Button2Click(TObject *Sender)
  29. {
  30. Form1->Table1->Prior();
  31. //向前移动一条记录
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TForm1::Button3Click(TObject *Sender)
  35. {
  36. Form1->Table1->Next();
  37. //移动到下一条记录
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TForm1::Button4Click(TObject *Sender)
  41. {
  42. Form1->Table1->Last();
  43. //移动到最后一条记录
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TForm1::Button5Click(TObject *Sender)
  47. {
  48. Form1->Table1->Insert();
  49. //在当前位置插入一条记录
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TForm1::Button6Click(TObject *Sender)
  53. {
  54. Form1->Table1->Delete();
  55. //删除当前记录
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TForm1::Button7Click(TObject *Sender)
  59. {
  60.    SavePlace=Form1->Table1->GetBookmark();
  61.    //在当前位置设置一个书签
  62. }
  63. //---------------------------------------------------------------------------
  64. void __fastcall TForm1::Button8Click(TObject *Sender)
  65. {
  66. if (SavePlace!="")
  67.    {
  68.    Form1->Table1->GotoBookmark(SavePlace);
  69.    //跳转到指定书签
  70.    }
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TForm1::Button9Click(TObject *Sender)
  74. {
  75. Form1->Table1->Close();
  76. //关闭数据库
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  80. {
  81. if (Form1->Table1->Eof)
  82.    {
  83.    Form1->Button4->Enabled=false;
  84.    Form1->Button3->Enabled=false;
  85.    }
  86.    else
  87.    {
  88.    Form1->Button4->Enabled=true;
  89.    Form1->Button3->Enabled=true;
  90.    }
  91.    //动态设置“Next”和“Last”按钮的有效状态
  92. if (Form1->Table1->Bof)
  93.    {
  94.    Form1->Button1->Enabled=false;
  95.    Form1->Button2->Enabled=false;
  96.    }
  97.    else
  98.    {
  99.    Form1->Button1->Enabled=true;
  100.    Form1->Button2->Enabled=true;
  101.    }
  102.    //动态设置“First”和“Prior”按钮的有效状态
  103. }
  104. //---------------------------------------------------------------------------