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

Example in Visual Basic

楼主#
更多 发布于: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 VB.
Private Const kNumberOfRows = 3
Dim theData(1 To 3, 1 To 2) As Variant
Private Sub Form_Load()
 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

 Map1.ZoomTo 800, -70.26, 44.05      `Zoom in on New England
End Sub
Private Sub Command1_Click()
 Dim flds As New MapXLib.Fields
 Dim ds As Dataset

 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.

 Set ds = Map1.Datasets.Add(miDataSetUnbound, Nothing, _
 "My Dataset", "State", , "USA", flds)
 `Create a theme based on the "Sales" column in the unbound dataset
 ds.Themes.Add miThemeGradSymbol, "Sales", "My Theme"
End Sub

Private Sub Map1_RequestData(ByVal DataSetName As String, _
 ByVal Row As Long, ByVal Field As Integer, _
 Value As Variant, Done As Boolean)
 Done = False
 If DataSetName <> "My Dataset" Or Row > kNumberOfRows Then
  Done = True
 Else
  Value = theData(Row, Field)

 End If
End Sub
喜欢0 评分0
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
游客

返回顶部