阅读:1519回复:2
Delphi Example of an Unbound Dataset
{ This sample demonstrates the use of Datasets.Add and the
RequestData event supported by MapX to build an unbound dataset, which allows MapX to access data whose format is known only to the programmer. In this example, the data is in the form of a two-dimensional array in Delphi.} { This line goes in TMapForm's Private declarations section } theData: array[1..3,1..2] of OleVariant; : : : const kNumberOfRows = 3; procedure TMapForm.FormCreate(Sender: TObject); begin theData[1,1] := 'ME'; // Fill in the data to theData[2,1] := 'NH'; // be used by RequestData theData[3,1] := 'VT'; theData[1,2] := 100; theData[2,2] := 200; theData[3,2] := 300; // Zoom in on New England Map1.ZoomTo(800, -70.26, 44.05); end; procedure TMapForm.UnboundButtonClick(Sender: TObject); var flds: CMapXFields; ds: Dataset; begin try // Create a new Fields object flds := CoFields.Create; // Describe the structure of the Unbound dataset flds.Add('State', 'State', miAggregationIndividual, miTypeString); flds.Add('Sales', 'Sales', miAggregationSum, miTypeNumeric); { Create the unbound dataset. The "RequestData" event will be triggered to get the data to be used. } ds := Map1.Datasets.Add(miDataSetUnbound, Null, 'My Dataset', 'State', EmptyParam, EmptyParam, flds, EmptyParam); { Create a theme based on the "Sales" column of the unbound dataset } ds.Themes.Add(miThemeGradSymbol, 'Sales', 'My Theme', EmptyParam); except on E: EOleException do Application.MessageBox(PChar(E.Message), 'Error', MB_OK or MB_ICONERROR); end; end; procedure TMapForm.Map1RequestData(Sender: TObject; const DataSetName: WideString; Row: Integer; Field: Smallint; var Value: OleVariant; var Done: WordBool); begin Done := false; If (DataSetName <> 'My Dataset') Or (Row > kNumberOfRows) Then Done := True Else Value := theData[Row, Field]; end; |
|
|
1楼#
发布于:2003-09-04 10:14
数据绑定的dephi代码,呵呵,dephi的朋友看看yo,楼上大哥能翻译成中文给大家看没,就very good啦,呵呵
|
|
|
2楼#
发布于:2003-11-27 20:27
谢谢
|
|