Custom Windows Forms Control not exporting functions, not showing in tools list, showing as Text
- by flavour404
Hi,
I have written a very simple control. C# Visual Studio 2008. Its output should be, and is a dll. I have added a reference to the dll within the project that I intend to use it with. The msdn article about how to write a control states that it should appear in the 'Add reference / projects' list, which it doesn't but I simply navigated to it under the 'browse' tab, went to the /bin folder and added the reference that way. I dragged it over to my toolbox, but it shows up as a 'Text:xhair_tool' and when i try and add it to a form, it won't, so what have I done wrong? It was created as a 'Windows forms control' project. It should export the one method which is 'Target' which return an array, as shown below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace xhair_tool
{
public partial class xhair : UserControl
{
public xhair()
{
InitializeComponent();
}
private void xhair_Load(object sender, EventArgs e)
{
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen pen = new Pen(Color.Black, 1);
SolidBrush redBrush = new SolidBrush(Color.Red);
g.DrawLine(pen, 8, 0, 8, 7);
g.DrawLine(pen, 8, 9, 8, 16);
g.DrawLine(pen, 0, 8, 7, 8);
g.DrawLine(pen, 9, 8, 16, 8);
//ControlPaint.DrawReversibleLine(start, end, backColor)
}
/// <summary>
/// Returns the point at the center of the crosshair
/// </summary>
/// <returns>int[x,y]</returns>
public int[] Target
{
get
{
int[] _xy = new int[2];
_xy[0] = this.Left + 8;
_xy[1] = this.Top + 8;
return _xy;
}
}
}
}
Thanks, R.