阅读:1311回复:1
请教大虾们两个很EASY的问题下面是我在刘光老师编的书上抄的一段代码,可是结果却和他的不一样. Dim shplayer As New MapObjects2.MapLayer Dim dc As New MapObjects2.DataConnection Dim gds As MapObjects2.GeoDataset Dim fname As String Private Sub open_Click() CommonDialog1.DialogTitle = "打开.shp文件" CommonDialog1.Filter = "ESRI Shapefile(*.shp)|*.shp" CommonDialog1.CancelError = True On Error GoTo errortrap CommonDialog1.ShowOpen If Len(CommonDialog1.FileName) = 0 Then Exit Sub dc.Database = CurDir If Not dc.Connect Then Exit Sub fname = Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4) Set gds = dc.FindGeoDataset(fname) If gds Is Nothing Then Exit Sub Set shplayer.GeoDataset = gds Map1.Layers.Add shplayer Exit Sub errortrap: If Err.Number <> 32755 Then MsgBox Err.Description, vbCritical End If Map1.Refresh End Sub 可是用这种方法加载图层后,只能显示第一次加载的图层,后面加载的没有.大家说问题在哪? 还有就是我得legend不是可以自动显示图层名称吗?怎么我得没有反应? 我写了如下代码: 在form_load: legend1.setmapsource.map1 legend1.loadlegend true 在legend1_aftersetlayervisible map1.refresh 请问还要在哪个地方写些什么代码才行吗? |
|
1楼#
发布于:2004-11-05 10:25
自己先顶一下,我今天又在toolbar的click里又加了一个刷新,但是它只能显示最后打开的一个文件。如果不用instr函数,请问还有什么方法可以打开多个文件吗?没有必要一次打开的。怎么没人跟帖?失败 |
|