Clear Shapefile category

hi,
i have created shapefile categories based on attributes on button click event. When i click the button again one more categories is created. How do i clear/remove the existing categories for all shapefiles.
Kindly check below code and attached jpg.
Below is the code:

for (int i = 0; i < ShapeFileList.Count; i++)
        {
            shapeFile = ShapeFileList[i] as MapWinGIS.Shapefile;
            
            if (shapeFile == null) { continue; }

            ShapeDrawingOptions options = shapeFile.DefaultDrawingOptions;
               
                options.PointType = tkPointSymbolType.ptSymbolStandard;
                options.FillColor = utils.ColorByName(tkMapColor.Red);
                ShapefileCategory ct = shapeFile.Categories.Add("OVER");
                Opattern.AddLine(utils.ColorByName(tkMapColor.Red), 5.0f, tkDashStyle.dsDash);
                ct.DrawingOptions.LinePattern = Opattern;                   
                ct.DrawingOptions.UseLinePattern = true;

                options.PointType = tkPointSymbolType.ptSymbolStandard;
                options.FillColor = utils.ColorByName(tkMapColor.Green);
                ShapefileCategory Uct = shapeFile.Categories.Add("UNDER");
                Upattern.AddLine(utils.ColorByName(tkMapColor.Green), 5.0f, tkDashStyle.dsDash);
                Uct.DrawingOptions.LinePattern = Upattern;                    
                Uct.DrawingOptions.UseLinePattern = true;


                options.PointType = tkPointSymbolType.ptSymbolStandard;
                options.FillColor = utils.ColorByName(tkMapColor.Blue);
                ShapefileCategory Nct = shapeFile.Categories.Add("NORMAL");
                Npattern.AddLine(utils.ColorByName(tkMapColor.Blue), 5.0f, tkDashStyle.dsDash);
                Nct.DrawingOptions.LinePattern = Npattern;                   
                Nct.DrawingOptions.UseLinePattern = true;

                options.PointType = tkPointSymbolType.ptSymbolStandard;
                options.FillColor = utils.ColorByName(tkMapColor.DarkGray);    
                ShapefileCategory Noct = shapeFile.Categories.Add("");
                Ncotpattern.AddLine(utils.ColorByName(tkMapColor.DarkGray), 5.0f, tkDashStyle.dsCustom);
                Noct.DrawingOptions.LinePattern = Ncotpattern;                    
                Noct.DrawingOptions.UseLinePattern = true;![te|283x500](upload://yEtFiDtbWwm3K11oFvPUi90K5NM.png)

I think you are looking for

shapeFile.Categories.Clear();

https://www.mapwindow.org/documentation/mapwingis4.9/class_shapefile_categories.html#acacc50655caa465c3c553a814ace8765

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.