Hi,
I want to add and delete layers when select and unselect comboboxes, it add layers correctly but when unselect the combobox to delete the layer it doesn't do anything, here is my code:
Private Sub DistChkBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DistChkBox.CheckedChanged
If DistChkBox.Checked = True Then
AddLayers(Distclass, "???????? ", objc.FeatureLayerDist)
Else
AxPageLayoutControl1.ActiveView.FocusMap.DeleteLayer(objc.FeatureLayerDist)
End If
End Sub
Private Sub SubDistChkBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubDistChkBox.CheckedChanged
If SubDistChkBox.Checked = True Then
AddLayers(SubDistclass, "??????? ", objc.FeatureLayerSubDist)
Else
AxPageLayoutControl1.ActiveView.FocusMap.DeleteLayer(objc.FeatureLayerSubDist)
End If
End Sub
Public Sub AddLayers(ByVal layersclass As FeatureClass, ByVal classes As String, ByVal pfeaturelayerd As IFeatureLayer)
Dim pfeaturelayer As IFeatureLayer
pfeaturelayer = New FeatureLayer
pfeaturelayer.FeatureClass = layersclass
pfeaturelayer.Name = classes & " " & objc.govlista
pfeaturelayer.ShowTips = True
AxPageLayoutControl1.ActiveView.FocusMap.AddLayer(pfeaturelayer)
pfeaturelayerd = pfeaturelayer
AxPageLayoutControl1.Refresh()
End Sub