frmtablefields.frm

来自「FloodEvaluation-程序是gis方面的程序」· FRM 代码 · 共 110 行

FRM
110
字号
VERSION 5.00
Begin VB.Form frmTableFields 
   Caption         =   "选择字段属性"
   ClientHeight    =   1335
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   2805
   Icon            =   "frmTableFields.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   1335
   ScaleWidth      =   2805
   StartUpPosition =   3  'Windows Default
   Begin VB.ComboBox ComboList 
      Height          =   315
      Left            =   120
      TabIndex        =   2
      Top             =   360
      Width           =   2535
   End
   Begin VB.CommandButton OK 
      Caption         =   "确 定"
      Height          =   375
      Left            =   480
      TabIndex        =   1
      Top             =   840
      Width           =   735
   End
   Begin VB.CommandButton Cancel 
      Caption         =   "退 出"
      Height          =   375
      Left            =   1680
      TabIndex        =   0
      Top             =   840
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "请从下拉框中选择所需字段:"
      Height          =   255
      Left            =   0
      TabIndex        =   3
      Top             =   0
      Width           =   2415
   End
End
Attribute VB_Name = "frmTableFields"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public pMap As IMap
Public selFieldStr As String
Public selLayerStr As String

Private Sub Cancel_Click()
    selFieldStr = ""
    Unload Me
End Sub

Private Sub Form_Load()
    
    ' Find the layer named STATES
    Dim pLayer As ILayer
    Dim pInputFeatLayer As IFeatureLayer
    Dim intCount As Integer
    For intCount = 0 To pMap.LayerCount - 1
      Set pLayer = pMap.Layer(intCount)
      If TypeOf pLayer Is IFeatureLayer Then
        If pLayer.name = selLayerStr Then
          Set pInputFeatLayer = pLayer
          Exit For
        End If
      End If
    Next
    
    If pInputFeatLayer Is Nothing Then
      MsgBox "The specified layer was not found!"
      Exit Sub
    End If
    
    ' Use the ITable interface from the FeatureLayer (not from the FeatureClass)
    Dim pInputTable As ITable
    Set pInputTable = pInputFeatLayer
  
    Dim pFields As IFields
    Set pFields = pInputTable.Fields
   
    If pMap Is Nothing Then
       MsgBox "图层字段列表初始化出错!"
       OK.Enabled = False
       Exit Sub
    End If
    
    For intCount = 0 To pFields.FieldCount - 1
       ComboList.AddItem pFields.Field(intCount).name
    Next
    
    If pFields.FieldCount > 0 Then ComboList.Text = pFields.Field(0).name
    
    selFieldStr = ""
  
End Sub

Private Sub OK_Click()
    selFieldStr = ComboList.Text
'    MsgBox selFieldStr
    Unload Me
End Sub

⌨️ 快捷键说明

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