FID value is -1... Help me please!!!!

Oct 27, 2012 at 5:48 AM
Edited Oct 27, 2012 at 5:56 AM

when modifying a layer by selection on the map, the FID value of selected items is always -1 who could help me?

 

 

Public Function FunctIMapLayer(AppManagerActual As AppManager, nameShape As String) As IMapLayer
	FunctIMapLayer=Nothing
	Try
		For Each actualLayer As ILayer In AppManagerActual.Map.MapFrame.GetAllLayers()
			If actualLayer.LegendText=nameShape Then
				FunctIMapLayer=actualLayer
				Exit Function
			End If
		Next
	Catch ex As Exception
		FunctIMapLayer=Nothing
		MsgBox("Error: " & ex.Message)
	End Try		
End Function
	
Public Sub ErrorFID()
    actualFLayer=CType(appManagerFunctions.FunctIMapLayer(appManager1,"WNODES"),FeatureLayer)
    If Not IsNothing(actualFLayer) Then
    	If actualFLayer.Selection.Count=1 Then
		Dim myClientPoint As New System.Drawing.Point(e.x,e.y)
		Dim myCoordinate As Coordinate= appManager1.Map.PixelToProj(myClientPoint)
    		'Error when FID=-1
    		'actualFLayer.Selection.ToFeatureList().Item(0).Fid = -1
Dim uFID As Integer=actualFLayer.Selection.ToFeatureList().Item(0).Fid
actualFLayer.DataSet.Features.Item(uFID).Coordinates(0)=myCoordinate actualFLayer.DataSet.InitializeVertices() actualFLayer.AssignFastDrawnStates() actualFLayer.DataSet.Save() map1.MapFrame.Invalidate() map1.Invalidate() appManager1.Map.Refresh() appManager1.Map.ResetBuffer()
actualFLayer.ClearSelection()
End If
End Sub
Nov 28, 2012 at 2:24 PM

Hi i faced the same problem and i came over this problem like this:
FeatureSet fsT = new FeatureSet(fs.Features);
so basically you are creating a new featureset at the beginning from your layer and then doing whatever analysis, selection, modify attribute on this new featureset and it works all fine.

try this and let me know if this helps

 

regards

irfan

Nov 28, 2012 at 5:30 PM

Hello..

The problem persists even so....

 

I'm currently doing this

Dim fLayerLinks As FeatureLayer		
For Each feature As IFeature In listSelection
  If Not IsDBNull(feature.ShapeIndex) Then
    MsgBox(fLayerLinks.DataSet.ShapeIndices.IndexOf(feature.ShapeIndex))
  Else
    MsgBox(feature.Fid)
  End If
Next

thanks irfan..

if you know how to improve it would be good... Thanks again