Hello, guys!
I wonder if there is a possibility to (visually and functionally) link two controls(components)? (.NET2)
Simplifying the things, I have two labels - one of them is the main label (it can be deplaced with the mouse) and an other - the description label - it needs to follow the main label on a specified distance.
Also, the description label should be able to respond to the events, like mouse click etc. Maybe there is a possibility to use a UserControl but between the labels I need to be a "transparent" space.
Thanks.
==EDIT 1==
I could also, instead of creating the second label control, just use a eternal toolTip. In this case i wonder about possibility of displaying it the Infinite time AND also possibility to detect the click on the tooltip.
Anyway, If I click on the label or tooltip, I will need to display to the user a TextBox control(instead of the tooltip or label), in order that it be able to Modify the displayed description (in fact displaying time)
== EDIT 2 ==
this is my "transperent" UserControl design
and this is my Form in running mode(user control "transparent" region covering a button).
this is the usercontrol's code:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace WindowsControlLibrary1
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020;//WS_EX_TRANSPARENT
return cp;
}
}
private int opacity;
public int Opacity
{
get { return opacity; }
set
{
opacity = value;
this.InvalidateEx();
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
Color bk = Color.FromArgb(Opacity, this.BackColor);
e.Graphics.FillRectangle(new SolidBrush(bk), e.ClipRectangle);
}
protected void InvalidateEx()
{
if (Parent == null)
return;
Rectangle rc = new Rectangle(this.Location, this.Size);
Parent.Invalidate(rc, true);
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Location = this.Location + (Size)e.Location;
}
}
Point cursorDownPoint = Point.Empty;
private void label1_MouseDown(object sender, MouseEventArgs e)
{
cursorDownPoint = label1.PointToScreen(e.Location);
}
}
}
=================
* The description was a little simplified. In my real case I have a custom circular point component (: from Microsoft.VisualBasic.PowerPacks.OvalShape). The point represents a object in time position - in the linked label I need to specify the point's time. User will be able to modify the point's time by clicking on the time label.