1、明确RAVE的结构:
RVproject->projman->dataview,report
dataview->stringfield, integerfield....
report->page->region->band,databand->text,datatext,memo,datamemo....
2、了解组件的类。
一般而言,组件的类名可以看RAVE设计器中的component前面的那个单词前面加上个TRave,如text,则其类为TRaveText, DataText类为TRaveDataText.
3、了解一定的联系。
这一点尤其是在创建DataText时要了解清楚。要创建一个DataText,则一定要有其对应的StringField,
IntegerField...,如果没有,则创建之。
4、了解要uses的units: Rave要uses的units较多,下面有个列表:
RvCsStd:TRaveText,TRaveMemo,TRaveSection,TRaveSection,TRaveMetaFile, TRaveFontMaster,TRavePageNumInit
RvClass:TRaveComponent,TRaveControl, TRaveContainerControl, TRaveContainerComponent,
TRaveProjectItem,TRavePage
RvCsData:TRaveDataText,TRaveDataMemo,TRaveCalcText,
TRaveDataMirrorSection,TRaveDataCycle,
TRaveCalcOp,TRaveCalcTotal,TRaveCalcController
RvCsBars:TRavePostNetBarCode,TRaveI2of5BarCode,TRaveCode39BarCode,TRaveCode128BarCode,
TRaveUPCBarCode,TRaveEANBarCode
RvCsDraw:
TRaveLine,TRaveHLine,TRaveVLine,TRaveRectangle, TRaveSquare,TRaveEllipse, TRaveCircle
RvDataField: TRaveStringField,TRaveIntegerField, TRaveBooleanField,TRaveFloatField,TRaveCurrencyField,
TRaveBCDField, TRaveDateField,TRaveTimeField,TRaveDateTimeField,TRaveBlobField,
TRaveMemoField,TRaveGraphicField,TRaveInt64Field
RvDatabase: TRaveDatabase
RvDirectDataView:
TRaveDataView,TRaveDriverDataView
RvProj:TRaveReport,TRaveProjectManager
RvSecurity:TRaveSimpleSecurity,TRaveLookupSecurity
RvCsRpt:TRaveRegion,TRaveBand,TRaveDataBand,TRaveIterateBand, TRaveBandStyle,TRaveDataCycle
5、实例:
uses
RpRave,
RVClass, RVProj, RvCsRpt, RVCsStd, RvCsData, RvDirectDataView, RvDataField;
procedure
TForm1.Button1Click(Sender: TObject);
var
MyPage: TRavePage;
MyBand: TRaveBand;
MyRegion: TRaveRegion;
mytext2: Travetext;
mydataband: Travedataband;
mydatatext: Travedatatext;
myDataView: TRaveDataView;
myfield: TraveStringField;
begin
form1.ADOQuery1.Close;
form1.ADOQuery1.SQL.Clear;
form1.ADOQuery1.SQL.Add('select name,mobile,hometele,CnD from address');
form1.ADOQuery1.Open;
form1.RvProject1.Open;
With RvProject1.ProjMan do
begin
MyPage:= FindRaveComponent('Report3.mainPage',nil) as TRavePage;
//查找page (注意,查找page,dataview后面的parent引用的是nil,而其他的页面上的对象引用时用page,比如说如果是某BAND下的一个TEXT,你不能引用这个BAND找到它,而是要用PAGE名。)
MyRegion:= FindRaveComponent('dataview1Region',MyPage) as TRaveRegion;
MyBand:= FindRaveComponent('DataView1Band',Mypage) as TRaveBand;
//MyBand:= TRaveBand(mypage.Components[3]);
MyText2:=TRaveText.Create(Myband);
MyText2.Parent:=Myband;
MyText2.Name:=GetUniqueName('Text125',MyPage,false);
MyText2.Top:=0;
MyText2.Left:=5.2;
MyText2.Width:=200;
MyText2.Height:=200;
MyText2.Text:='号码';
MyText2.Font.Size :=15;//设置字体的属性
MyText2.Font.Color :=Clmaroon;
MyText2.Font.Name :='宋体';
AddComponent(MyText2);
//建立新文本,TraveText,列标题。
myDataView:=FindRaveComponent('DataView1',nil) as TraveDataView;
//myDataView:=TraveDataView(rvproject1.ProjMan.Components[0]);
myfield:=TRaveStringField.Create(myDataView);
myfield.Parent:=myDataView;
myfield.Name:='dataview1CnD';
myfield.FieldName:='CnD';
myfield.FullName:='CnD';
myfield.Size:=4;
addcomponent(myfield); //建立新的字段,tStringfield,字段。
MydataBand := FindRaveComponent('dataview1dataBand',Mypage) as TRavedataBand;
//MydataBand := TRavedataBand(mypage.Components[8]);
Mydatatext:=TRavedataText.Create(Mydataband);
Mydatatext.Parent:=Mydataband;
Mydatatext.Name:=GetUniqueName('dataText125',Mypage,false);
Mydatatext.Top:=0;
Mydatatext.Left:=5.2;
Mydatatext.Width:=1;
Mydatatext.Height:=200;
mydatatext.DataView := myDataView;
mydatatext.DataField:='CnD';
Mydatatext.Font.Size :=12;//设置字体的属性
Mydatatext.Font.Color :=Clblack;
Mydatatext.Font.Name :='宋体';
AddComponent(Mydatatext);
//建立新的列,Tdatatext,字段内容。
end;
form1.RvProject1.Execute;
rvproject1.Close;