I am sending you my code which I use for programmatically adding groups and layers.
1. When save this content to the map file with Save MAP and reopen it with Open MAP it shows all the content OK.
2. When define the dynamic visibility (Layer.cs: MapFrame.Extents.Width) program stopped
3. When select Selection from menu and Select by Attributes option which opens Select By Attributes window. There is Layer list box empty and also Field Names are empty.
4. When open the Attribute table Editor window sometimes there are data records with strange content, but if open layer with command FillAttributes data are OK.
5. I just downloaded MW6 application (ZippedRelease.zip Jun 15) and set new group in the legend with your application, then added data and move this feature layer to new group.
Follow with Save map and reopen with Open Map. And now tried to set dynamic visibility for the layer and program stopped as in my own case with programmatically
added groups and layers.
I will be very happy if you have time to give me some directions how to programmatically load groups and layers in correct way.
Best regards, Vojko
I changed the method "public virtual List<IMapLayer> AddLayers()" in Map.cs with my code to add new group with name "GROUP 1" and new layer to this group:
public virtual List<IMapLayer> AddLayers()
List<IDataSet> sets = DataManager.DefaultDataManager.OpenFiles();
if (sets == null || sets.Count == 0) return null;
List<IMapLayer> results = new List<IMapLayer>();
foreach (IDataSet set in sets)
if (set == null) return null;
IFeatureSet fs = set as IFeatureSet;
if (fs != null)
// is this "GROUP 1" group already in legend or not?
foreach (ILayer layer in Layers)
IGroup grp = layer as IGroup;
if (grp != null)
if (grp.LegendText == "GROUP 1")
mgrp.LegendText = "GROUP 1";
// overlap or not other layers
ins = 1;
// or only add on the top of other layers
// adding my new line layer to this group