Daniel said:
It would help if you said what the error is rather than just "there is a
problem"... anyway...
I don't see where you create the object... maybe you should change the
declaration line to:
public Linia ln = new Linia();
Also you'll have to make the constructor of Linia public:
public Linia() {
Yes, indeed in this case it works perfect, but in my more complicated example i
have the same problem wharever i create that public or not. I pass elements to
invoke function, maybe there is somethin wrong with onpaint function from the
line class?
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
if (xLeft <= xRight)
{
Left = xLeft;
}
else
{
Left = xRight;
}
if (yLeft <= yRight)
{
Top = yLeft;
}
else
{
Top = yRight;
}
SolidBrush brush = new SolidBrush(this.Parent.BackColor);
e.Graphics.FillRectangle(brush, 0, 0, this.Width, this.Height);
Pen pen = new Pen(_color);
if (xLeft < xRight & yLeft < yRight)
{
e.Graphics.DrawLine(pen, 0, 0, this.Width, this.Height);
}
else if (xLeft > xRight & yLeft < yRight)
{
e.Graphics.DrawLine(pen, this.Width, 0, 0, this.Height);
}
else if (xLeft > xRight & yLeft > yRight)
{
e.Graphics.DrawLine(pen, this.Width, this.Height, 0, 0);
}
else if (xLeft < xRight & yLeft > yRight)
{
e.Graphics.DrawLine(pen, 0, this.Height, this.Width, 0);
}
}
And when i'm debugging my program stopped with
An unhandled exception of type 'System.ArgumentException' occurred in
System.Windows.Forms.dll
Additional information: ArgumentException when i'm trying to add my ln to
Controls. I have no other idea what else?