I am having an issue when adding or deleting shapes using the shape editor with the shapefiles being corrupted. It only happens the second time the shapefile is opened for editing using the StartEditingShapes function. I have created a very simple form showing the code I’m using.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim sf As New Shapefile
sf.Open("L:\Test\SUBDIV.shp")
AxMap1.AddLayer(sf, True)
End Sub
Private Sub CmdStartEdit_Click(sender As Object, e As EventArgs) Handles CmdStartEdit.Click
Dim sf As Shapefile = AxMap1.get_Shapefile(0)
sf.StartEditingShapes(True)
sf.InteractiveEditing = True
AxMap1.CursorMode = tkCursorMode.cmEditShape
End Sub
Private Sub CmdSaveEdit_Click(sender As Object, e As EventArgs) Handles CmdSaveEdit.Click
Dim sf As Shapefile = AxMap1.get_Shapefile(0)
sf.StopEditingShapes(True, True)
sf.InteractiveEditing = False
sf.Save()
AxMap1.CursorMode = tkCursorMode.cmSelection
End Sub
Private Sub CmdEditShapes_Click(sender As Object, e As EventArgs) Handles CmdEditShapes.Click
AxMap1.CursorMode = tkCursorMode.cmEditShape
End Sub
Private Sub CmdAddShapes_Click(sender As Object, e As EventArgs) Handles CmdAddShapes.Click
AxMap1.CursorMode = tkCursorMode.cmAddShape
End Sub
Private Sub AxMap1_ChooseLayer(sender As Object, e As _DMapEvents_ChooseLayerEvent) Handles AxMap1.ChooseLayer
e.layerHandle = 0
End Sub
The After clicking the StartEdit button and adding 2 or more polygons and saving the changes using the SaveEdit button everything seems to be fine, however the second time you select the StartEdit button, add polygons and save the changes you can tell something is wrong because you can’t select the added shapes. At this point the shapefile will crash if you try to reload it. Am I missing a step in opening or saving the shapefile for editing. This is the same syntax we used with 4.9 and I didn’t notice the issue then.
I have tried this with different shapefiles with the same results.