Unit1.cpp
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:3k
- /*============================} unit Unit1; {==================================}
- { Main properties were set at design time: }
- { Table1->TableName = "SampleTable.db"; // Paradox table }
- { Table1->ReadOnly = false; }
- { DataSource1->Dataset = Table1; }
- { DBNavigator1->DataSource = DataSource1; }
- { DBEdit1->DataSource = DataSource1; }
- { DBRichView1->DataSource = DataSource1; }
- { DBRichView1->Style = RVStyle1; }
- { DBEdit1->DataField = "Caption"; // Alphanumeric field }
- { DBRichViewEdit1->DataField = "RVFField"; // Binary field }
- { nbEdit was removed from DBNavigator1->VisibleButtons (because of autoedit) }
- {------------------------------------------------------------------------------}
- { Note: changes after last posting are not saved when exiting application. }
- {=============================================================================*/
- #include <vclvcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- #include "Unit2.h"
- //---------------------------------------------------------------------------
- #pragma link "DBRV"
- #pragma link "RichView"
- #pragma link "RVScroll"
- #pragma link "RVStyle"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- // Opening table...
- Table1->DatabaseName = ExtractFilePath(Application->ExeName);
- Table1->Open();
- RVStyle1->TextStyles->Items[1] = RVStyle1->TextStyles->Items[0];
- RVStyle1->TextStyles->Items[1]->Style << fsBold;
- }
- //---------------------------------------------------------------------------
- void TForm1::UpdateStatusLabel()
- {
- if (Table1->RecordCount==0)
- Label3->Caption = "(empty)";
- else if (Table1->RecNo<1)
- Label3->Caption = "(new)";
- else
- Label3->Caption = Format("Record %d of %d", ARRAYOFCONST(((int)Table1->RecNo, (int)Table1->RecordCount)));
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::DataSource1DataChange(TObject *Sender, TField *Field)
- {
- UpdateStatusLabel();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- // See Unit2.pas
- Form2->SetField("RVFField",Table1);
- Form2->ShowModal();
- }
- //---------------------------------------------------------------------------