用户操作
[即时聊天] [发私信] [加为好友]
南瓜ID:jaanna
1193次访问,排名2万外好友2人,关注者4
人老了,才发现什么都不会。
jaanna的文章
原创 16 篇
翻译 0 篇
转载 11 篇
评论 0 篇
最近评论
文章分类
收藏
    相册
    房子车子票子
    孩子
    旅游足迹
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 vb+ae属性查询函数收藏

    新一篇: vb+ae '图层查找函数 | 旧一篇: 打开保存mxd文件

      '属性查询函数
        Private Sub QueryByAttribute(ByRef operator As esriSelectionResultEnum)
            Dim pFeatureLayer As IGeoFeatureLayer
            Dim j As Integer
            Dim i As Integer
            Dim pFeatureselection As IFeatureSelection
            Dim pActiveView As IActiveView
            Dim pFields As IFields
            Dim pField As IField
            Dim FieldID As Integer
            Dim operatorString As String
            Dim whereClause As String
            Dim pFilter As IQueryFilter
            Dim attName As String
            Dim attValue As Object

            On Error GoTo ErrorHandler

            '选择一个查询的条件,从下面的COMBO中。
            If ((lstAttribute.SelectedItems.Count < 1) Or (txtValue.Text = "")) Then
                GiveWarning("警告", "你必须选择一个属性值!")
                Exit Sub
            End If

            For i = 0 To lstAttribute.Items.Count - 1
                If (lstAttribute.GetSelected(i)) Then
                    attName = VB6.GetItemString(lstAttribute, i)
                    i = lstAttribute.Items.Count
                End If
            Next i

            Select Case cboOperator.Text
                Case "等于"
                    operatorString = "="
                Case "不等于"
                    operatorString = "<>"
                Case "小于"
                    operatorString = "<"
                Case "大于"
                    operatorString = ">"
                Case "小于或等于"
                    operatorString = "<="
                Case "大于或等于"
                    operatorString = ">="
            End Select

            pActiveView = m_pMap
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
            For j = 0 To lstClass.Items.Count - 1
                If (lstClass.GetSelected(j)) Then
    word="vbup1037"”
                    If (FoundLayer(VB6.GetItemString(lstClass, j), pFeatureLayer)) Then
                        pFeatureselection = pFeatureLayer
                        If (pFeatureLayer.Selectable) Then
                            ' Must convert the attribute value to the correct type
                            '必须以准确的类型传递属性值。
                            pFields = pFeatureLayer.FeatureClass.Fields
                            FieldID = pFeatureLayer.FeatureClass.FindField(attName)
                            pField = pFields.Field(FieldID)
                            attValue = txtValue.Text
                            Select Case pField.Type
                                '字段的类型。
                            Case esriFieldType.esriFieldTypeInteger
                                    attValue = CShort(attValue)
                                Case esriFieldType.esriFieldTypeSingle
                                    attValue = CShort(attValue)
                                Case esriFieldType.esriFieldTypeSmallInteger
                                    attValue = CShort(attValue)
                                Case esriFieldType.esriFieldTypeDouble
                                    attValue = CDbl(attValue)
                                Case esriFieldType.esriFieldTypeOID
                                    attValue = CInt(attValue)
                                Case esriFieldType.esriFieldTypeString
                                    attValue = CStr(attValue)
                                    attValue = "'" & CStr(attValue) & "'"
                            End Select
                            whereClause = attName & operatorString & " " & CStr(attValue)
                            '设置条件,进行查询过滤。
                            pFilter = New QueryFilter
                            pFilter.SubFields = "*"
                            pFilter.WhereClause = whereClause
                            pFilter.OutputSpatialReference(attName) = m_pMap.SpatialReference
                            pFeatureselection.SelectFeatures(pFilter, operator, False)
                        Else
                            If (operator = esriSelectionResultEnum.esriSelectionResultNew) Then pFeatureselection.Clear()
                        End If
                    End If
                Else
    word="vbup1037"”
                    If (FoundLayer(VB6.GetItemString(lstClass, j), pFeatureLayer)) Then
                        pFeatureselection = pFeatureLayer
                        If ((operator = esriSelectionResultEnum.esriSelectionResultNew) Or (operator = esriSelectionResultEnum.esriSelectionResultAnd)) Then pFeatureselection.Clear()
                    End If
                End If
            Next j
            System.Diagnostics.Debug.WriteLine(pFeatureLayer.Name)
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
            '  m_pApp.StatusBar.message(0) = "被选择的对象数目为: " & CStr(m_pMap.SelectionCount)
            RefreshSelectButtons()

            Exit Sub
    ErrorHandler:
            MsgBox("An unexpected error has occured with the Selection Dialog." & vbCr & vbCr & "Details : " & Err.Description, MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "Error")
        End Sub


    发表于 @ 2007年11月05日 23:07:00|评论(loading...)|编辑|收藏

    新一篇: vb+ae '图层查找函数 | 旧一篇: 打开保存mxd文件

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © 南瓜