P
Przemek
Hello,
I write a little UserControl
-------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace UserControlPoint
{
public class ChartPoint : System.Windows.Forms.UserControl
{
private ContainerControl _containerControl = null;
public ContainerControl ContainerControl
{
get { return _containerControl; }
set { _containerControl = value; }
}
public ChartPoint()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// ChartPoint
//
this.BackColor = System.Drawing.Color.Transparent;
this.Name = "ChartPoint";
this.Size = new System.Drawing.Size(20, 20);
//this.Paint += new
System.Windows.Forms.PaintEventHandler(this.ChartPoint_Paint);
//this.MouseLeave += new
System.EventHandler(this.ChartPoint_MouseLeave);
//this.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.ChartPoint_MouseMove);
this.ResumeLayout(false);
}
}
}
-------
and when I want to use it in second UserControl
-------
....
for (int i = 0; i < mypointsdataarray.Length; i++)
{
convertedpoints =
TransformPoint(mypointsdataarray);
/*
Panel panel = new Panel();
panel.BackColor = Color.Red;
panel.Size = new Size(4, 4);
panel.Location = new Point(convertedpoints.X -
2, convertedpoints.Y - 2);
this.Controls.Add(panel);
*/
ChartPoint chartpoint = new ChartPoint();
chartpoint.Location = new
Point(convertedpoints.X - 10, convertedpoints.Y - 10);
this.Controls.Add(chartpoint);
}
....
-------
I put second UserControl on default Form Application, with buttons.
And when I click one of this buttons actions described in loop above
is running. BUT ... this code give me a "Error creating window
handle." message, so I try to do this without my ChartPoint
UserControl and I test default Panel Component and every thing works
fine. So What is wrong with my ChartPoint UserControl, because I don't
know what I'm doing wrong.
Best Regards
Przemek
I write a little UserControl
-------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace UserControlPoint
{
public class ChartPoint : System.Windows.Forms.UserControl
{
private ContainerControl _containerControl = null;
public ContainerControl ContainerControl
{
get { return _containerControl; }
set { _containerControl = value; }
}
public ChartPoint()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// ChartPoint
//
this.BackColor = System.Drawing.Color.Transparent;
this.Name = "ChartPoint";
this.Size = new System.Drawing.Size(20, 20);
//this.Paint += new
System.Windows.Forms.PaintEventHandler(this.ChartPoint_Paint);
//this.MouseLeave += new
System.EventHandler(this.ChartPoint_MouseLeave);
//this.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.ChartPoint_MouseMove);
this.ResumeLayout(false);
}
}
}
-------
and when I want to use it in second UserControl
-------
....
for (int i = 0; i < mypointsdataarray.Length; i++)
{
convertedpoints =
TransformPoint(mypointsdataarray);
/*
Panel panel = new Panel();
panel.BackColor = Color.Red;
panel.Size = new Size(4, 4);
panel.Location = new Point(convertedpoints.X -
2, convertedpoints.Y - 2);
this.Controls.Add(panel);
*/
ChartPoint chartpoint = new ChartPoint();
chartpoint.Location = new
Point(convertedpoints.X - 10, convertedpoints.Y - 10);
this.Controls.Add(chartpoint);
}
....
-------
I put second UserControl on default Form Application, with buttons.
And when I click one of this buttons actions described in loop above
is running. BUT ... this code give me a "Error creating window
handle." message, so I try to do this without my ChartPoint
UserControl and I test default Panel Component and every thing works
fine. So What is wrong with my ChartPoint UserControl, because I don't
know what I'm doing wrong.
Best Regards
Przemek