袁绍伦
路人甲
路人甲
  • 注册日期2003-08-08
  • 发帖数654
  • QQ164646905
  • 铜币1336枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1519回复:2

Delphi Example of an Unbound Dataset

楼主#
更多 发布于:2003-09-03 21:43
{ 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;
喜欢0 评分0
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2003-09-04 10:14
数据绑定的dephi代码,呵呵,dephi的朋友看看yo,楼上大哥能翻译成中文给大家看没,就very good啦,呵呵
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
xiaonai
路人甲
路人甲
  • 注册日期2003-11-27
  • 发帖数87
  • QQ
  • 铜币418枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2003-11-27 20:27
谢谢
举报 回复(0) 喜欢(0)     评分
游客

返回顶部