When I give mouse potion to label, it appear much down and left to the current mouse position. Label inside one group box and group box contain more then 50% of the form area. Group Box is compulsory here. I'm trying with this code.
int xX, yY = 0;
protected override void OnMouseMove(MouseEventArgs e) {
base.OnMouseMove(e);
xX = e.X;
yY = e.Y;
lbl.Left = xX;
lbl.Top = yY;
}
It looks like you want to move the label within the boundaries of a panel, so you should add an event handler for the MouseMove event of the panel.
public Form1()
{
InitializeComponent();
panel1.MouseMove += panel1_MouseMove;
}
void panel1_MouseMove(object sender, MouseEventArgs e)
{
lbl.Location = e.Location;
}
public frmChequeFormat()
{
InitializeComponent();
gbCheque.MouseMove += gbCheque_MouseMove;
}
bool mDown = false;
private void gbCheque_MouseMove(object sender, MouseEventArgs e)
{
if (mDown)
{
label13.Location = e.Location;
}
}
private void label13_MouseDown(object sender, MouseEventArgs e)
{
mDown = true;
}
private void label13_MouseUp(object sender, MouseEventArgs e)
{
mDown = false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.