echo2003
点子王
点子王
  • 注册日期2003-07-28
  • 发帖数2453
  • QQ76947571
  • 铜币5473枚
  • 威望1点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
10楼#
发布于:2003-12-18 17:14
看看下面这个例子,你可以参考:
procedure TMapForm.SafeArrayButtonClick(Sender: TObject);
var
 theData: Variant; // Safe Array of data
 flds: CMapXFields;
 ds: Dataset;
begin
 { Create a new SafeArray and fill it with sample data. }
 theData := VarArrayCreate([1,3, 1, 2], varVariant);
 theData[1,1] := 'ME';
 theData[2,1] := 'NH';
 theData[3,1] := 'VT';
 theData[1,2] := 100;
 theData[2,2] := 200;
 theData[3,2] := 300;

 try
  { Create a new fields object }
  flds := CoFields.Create;
  { Describe the structure of the SafeArray, so that our
    columns will have names after the Datasets.Add }

  flds.Add(1, 'State', miAggregationIndividual, miTypeString);
  flds.Add(2, 'Sales', miAggregationSum, miTypeNumeric);

  { Create a SafeArray dataset. }
  ds := Map1.Datasets.Add(miDataSetSafeArray, theData, 'My Dataset', 1, EmptyParam, EmptyParam, flds, EmptyParam);

  { Create a theme based on the "Sales" column in the new
    dataset }
  ds.Themes.Add(miThemeIndividualValue, 'Sales', 'My Theme', EmptyParam);
 except
  on E: EOleException do
   Application.MessageBox(PChar(E.Message), 'Error',
    MB_OK or MB_ICONERROR);

 end;
end;
举报 回复(0) 喜欢(0)     评分
上一页 下一页
游客

返回顶部