GetEnumerator for Layer

Hello!
I have the following code -
GoDocument diagram = new GoDocument();
GoView view = new GoView(diagram);
view.Dock = DockStyle.Fill;
this.Controls.Add(view);
GoLayer layer1 = diagram.Layers.CreateNewLayerAfter(null);
GoText txt = new GoText();
txt.Text = “Howdy”;
txt.Visible = true;
txt.Position = new PointF(100, 100);
diagram.Add(txt); & nbsp;
GoText t2 = new GoText();
t2.Text = “Layer 2. wow!!”;
t2.Position = new PointF(50, 50);
t2.Visible = true;
layer1.Add(t2);
I have a couple of questions now -
* Is txt added to the default layer of diagram?
* How can I get the enumerator for layer1? I want to do something like -
GoLayerEnumerator browseLayer = diagram.DefaultLayer.GetEnumerator();
but I want the enumerator for layer1.
Thanks,
Pradip

I’ve simplified your code and added some code and comments:
GoView view = new GoView();
view.Dock = DockStyle.Fill;
this.Controls.Add(view);
GoDocument diagram = view.Document;
GoLayer layer1 = diagram.Layers.CreateNewLayerAfter(null);
GoText txt = new GoText();
txt.Text = “Howdy”;
txt.Position = new PointF(100, 100);
diagram.Add(txt); // added to diagram.DefaultLayer
GoText t2 = new GoText();
t2.Text = “Layer 2. wow!!”;
t2.Position = new PointF(50, 50);
layer1.Add(t2);
foreach (GoObject obj in layer1) { // shift all objects in layer1 to the right
obj.Left += 10;
}
Yes, the txt object was added to the default layer of the diagram.
GoLayer implements the IGoCollection interface, which also implements ICollection, so you can call GetEnumerator() if you need to. But it’s far more common just to use “foreach”.
GoDocument, GoGroup, and GoCollection and GoSelection also implement the IGoCollection interface. A lot of methods take IGoCollection as an argument, so this gives you a lot of flexibility in how you manipulate collections of GoObjects.