Deleting particular line in linelayer on map.

Mar 16, 2012 at 10:48 AM

Hi all!

In my program I need to delete the selected line in linelayer on map. Any suggestion?

I have tried this but its not working.

code =>

List ls1 = new List();               
FeatureLayer fl1 = map1.Layers[0] as FeatureLayer;               
ISelection il1 = fl1.Selection;
 try               
{                   
	ls1 = il1.ToFeatureList();                   
	if (islinedel == true)          //Code for deleting selected line                   
	{                                               
		for (int j = 0; j< il1.Count; j++)                       
		{                           
			string fx, fy,lx,ly;                           
			string[] firstsplit = ls1[j].DataRow.ItemArray.GetValue(4).ToString().Split(',');                           

			string[] lastsplit = ls1[j].DataRow.ItemArray.GetValue(5).ToString().Split(',');
                            	fx = firstsplit[0].TrimStart('(');                           
				fy = firstsplit[1];                           
				lx = lastsplit[0].TrimStart('(');                           
				ly = lastsplit[1];

                            fcod.X = double.Parse(fx);                            
			fcod.Y = double.Parse(fy);
                            lcod.X = double.Parse(lx); 
                           lcod.Y = double.Parse(ly);

			// lineF is the featureset on the map containing linelayer
                            IFeature delFeature = lineF.Features[lineF.Features.Count - 1];                            
                            delFeature.Coordinates.Remove(fcod); 

                               delFeature.Coordinates.Remove(lcod);                           
				lineF.InitializeVertices();                           
			        map1.FunctionMode = FunctionMode.None;                           
				map1.ResetBuffer();                           
				islinedel = false;                                                 

			}                                           
	}
}
catch               
{                   
	MessageBox.Show("Cannot delete this line!!");               
}

 

Can any one please suggest something??