problem: save layer programmatically using engine

627
0
11-09-2011 05:43 PM
RoszainezaAlwi
New Contributor
Hi, i'm new to gis development..i currently working on application development using arcgis engine. I'm trying to solve this problem in my code. Can anybody help me check this code..

Sub SetEditLayer(ByVal sLayerName As String)

        Dim pDoc As IActiveView
        Dim pLayer As IFeatureLayer
        Dim pMap As IMap
        Dim pmxapp As IMxApplication
        'Get the editor object
        Dim pID As New UID
        pID = "esriCore.Editor"
        Dim pEditor As IEngineEditor
        pEditor = pmxapp.FindExtensionByCLSID(pID)

        Dim pEditLayers As IEngineEditLayers
        pEditLayers = pEditor

        pDoc = MainForm.axMapControl1.ActiveView
        pMap = pDoc.FocusMap

        'Set edit layer
        For i = 0 To pMap.LayerCount - 1
            If UCase(pMap.Layer(i).Name) = UCase(sLayerName) Then
                pLayer = pMap.Layer(i)
                Exit For
            End If
        Next

        Dim pFeatureLayer As IFeatureLayer
        pFeatureLayer = pLayer
        Dim pDataset As IDataset
        pDataset = pFeatureLayer.FeatureClass

        'Start editing the workspace of this featureclass
        If pEditor.EditState = esriEngineEditState.esriEngineStateNotEditing Then
            pEditor.StartEditing(pDataset.Workspace, MainForm.axMapControl1)
            pEditor.StartOperation()
        End If
        pEditLayers.SetCurrentLayer(pLayer, 0)
    End Sub

Is it ok for me to use "esriCore.Editor"? cause i'm using engine for development. Please guide me..thanks..
Tags (2)
0 Kudos
0 Replies