DataEdit.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:3k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "DataEdit.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- TBookmark SavePlace;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Form1->Timer1->Enabled=true;
- //设置控件的有效状态
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- Form1->Table1->First();
- //移动到第一条记录
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- Form1->Table1->Prior();
- //向前移动一条记录
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- Form1->Table1->Next();
- //移动到下一条记录
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button4Click(TObject *Sender)
- {
- Form1->Table1->Last();
- //移动到最后一条记录
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5Click(TObject *Sender)
- {
- Form1->Table1->Insert();
- //在当前位置插入一条记录
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button6Click(TObject *Sender)
- {
- Form1->Table1->Delete();
- //删除当前记录
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button7Click(TObject *Sender)
- {
- SavePlace=Form1->Table1->GetBookmark();
- //在当前位置设置一个书签
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button8Click(TObject *Sender)
- {
- if (SavePlace!="")
- {
- Form1->Table1->GotoBookmark(SavePlace);
- //跳转到指定书签
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button9Click(TObject *Sender)
- {
- Form1->Table1->Close();
- //关闭数据库
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- if (Form1->Table1->Eof)
- {
- Form1->Button4->Enabled=false;
- Form1->Button3->Enabled=false;
- }
- else
- {
- Form1->Button4->Enabled=true;
- Form1->Button3->Enabled=true;
- }
- //动态设置“Next”和“Last”按钮的有效状态
- if (Form1->Table1->Bof)
- {
- Form1->Button1->Enabled=false;
- Form1->Button2->Enabled=false;
- }
- else
- {
- Form1->Button1->Enabled=true;
- Form1->Button2->Enabled=true;
- }
- //动态设置“First”和“Prior”按钮的有效状态
- }
- //---------------------------------------------------------------------------