Problem with GoObject

Hello.
I Create a class that inherits from GoObject where I have 2 GoRectangule within a GoGroup.

namespace objTeclado
{
class prueba : GoObject
{
public void a()
{

        GoGroup g = new GoGroup();
        GoRectangle r1 = new GoRectangle();
        r1.Size = new SizeF(100,100);
        r1.BrushColor = Color.Aqua;
        g.Add(r1);

        GoRectangle r2 = new GoRoundedRectangle();
        r2.Size = new SizeF(100, 100);
        r2.FillSimpleGradient(Color.LightGreen, Color.Green, GoObject.TopCenter);
        r2.Pen = null;
        g.Add(r2);
    }
}

}

To use, I create an object in Form1 but when I add to Goview not shown me anything. Unhappy

public Form1(){
InitializeComponent();

        view.Dock = DockStyle.Fill;
        this.Controls.Add(view);

        prueba p = new prueba();
        p.a(view.Document);
        view.Document.Add(p);
        p.Position = new PointF(10, 10);

}

Thanks.

Right. GoObject is a primitive… it isn’t a container for other objects… that’s GoGroup.

if I change your code to this:


  [Serializable]   
  class prueba : <font color="#ff0000">GoGroup</font>
    {
        public prueba()
        {
            GoRectangle r1 = new GoRectangle();
            r1.Size = new SizeF(100,100);
            r1.BrushColor = Color.Aqua;
            <font color="#ff0000">this</font>.Add(r1);

            GoRectangle r2 = new GoRoundedRectangle();
            r2.Size = new SizeF(100, 100);
            r2.FillSimpleGradient(Color.LightGreen, Color.Green, GoObject.TopCenter);
            r2.Pen = null;
            <font color="#ff0000">this</font>.Add(r2);
        }
    }

and create an instance with this:

[code] prueba pb = new prueba();
pb.Position = new PointF(500, 500);
doc.Add(pb);

[/code]

I get:

note, though, since they are both selectable, etc… they don’t really act as a group:

you will only see the “group” if you drag-box select around both rectangles.

To avoid the problem that Jake points out in the modified code, set Selectable to false for each of the GoRectangles.

Also within the group you probably want to position the child objects so that they don’t overlap exactly. But I assume your code was just for demonstration purposes, not what you are actually trying to do.

@Jake: Thank you, had not provided it, but I resolved.

@Walter: Yes, my code is only a demonstration, Thank you.