form3.frm

来自「运行程序前请先把"地图"文件夹中的地图集和图层拷到mapX4.0的maps文件夹」· FRM 代码 · 共 218 行

FRM
218
字号
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form Form2 
   ClientHeight    =   2730
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8130
   LinkTopic       =   "Form3"
   ScaleHeight     =   2730
   ScaleWidth      =   8130
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "查找"
      Height          =   495
      Left            =   7080
      TabIndex        =   5
      Top             =   120
      Width           =   975
   End
   Begin VB.ComboBox Combo2 
      Height          =   300
      Left            =   5040
      TabIndex        =   3
      Top             =   240
      Width           =   1815
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "Form3.frx":0000
      Left            =   1560
      List            =   "Form3.frx":0002
      TabIndex        =   2
      Top             =   240
      Width           =   1935
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   480
      Top             =   1920
      Visible         =   0   'False
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Bindings        =   "Form3.frx":0004
      Height          =   735
      Left            =   240
      TabIndex        =   0
      Top             =   840
      Width           =   7575
      _ExtentX        =   13361
      _ExtentY        =   1296
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label Label2 
      Caption         =   "选择一个地物:"
      Height          =   255
      Left            =   3720
      TabIndex        =   4
      Top             =   240
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "选择一个图层:"
      Height          =   255
      Left            =   240
      TabIndex        =   1
      Top             =   240
      Width           =   1215
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_click()
   Dim lyr As Layer, rvs As MapXLib.RowValues
   Dim flds As MapXLib.Fields
   Dim fld As MapXLib.Field
   Dim ds As MapXLib.Dataset
  Dim i As Integer
  Dim lyrname As String
  Dim ftrs As MapXLib.Features
  i = Combo1.ListIndex
  Combo2.Clear
  Set lyr = Form1.Map1.Layers.Item(i + 1)
  Set ftrs = lyr.AllFeatures
  Set ds = Form1.Map1.Datasets.Add(miDataSetLayer, lyr) '数据绑定
  For i = 1 To ftrs.Count
      Set rvs = ds.RowValues(ftrs.Item(i)) 'ftr对象的属性数据
      lyrname = ds.Fields.Item(1).Name & ":" & rvs.Item(1).Value
      Combo2.AddItem lyrname
  Next i
End Sub

Private Sub Command1_Click()
  Dim lyrstring, ftrstring As String
  ftrstring = Right$(Combo2.Text, 1)
  Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Gonlae\桌面\MapX程序\guanwang.mdb;Persist Security Info=False"
      Select Case Combo1.Text
             Case "电力改"
                  Adodc1.RecordSource = "select * from dianli where 电力线ID='" & ftrstring & "'"
             Case "给水改"
                 Adodc1.RecordSource = "select * from geishui where 给水管ID='" & ftrstring & "'"
             Case "公路改"
                Adodc1.RecordSource = "select * from gonglu where 公路ID='" & ftrstring & "'"
             Case "排水改"
               Adodc1.RecordSource = "select * from paishui where 排水管ID='" & ftrstring & "'"
             Case "宿舍"
               Adodc1.RecordSource = "select * from sushe where 宿舍ID='" & ftrstring & "'"
             Case "排水节点"
               Adodc1.RecordSource = "select * from paishuijiedian where 排水节点ID='" & ftrstring & "'"
     End Select
     Adodc1.Refresh
End Sub
Private Sub Form_Load()
Dim i As Integer
Combo1.Clear
For i = 1 To Form1.Map1.Layers.Count
    Combo1.AddItem Form1.Map1.Layers(i).Name
Next i
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?