永发信息网

c#中如何改变控件位置.?

答案:3  悬赏:30  手机版
解决时间 2021-03-26 03:38
  • 提问者网友:轮囘Li巡影
  • 2021-03-25 21:49
c#中如何改变控件位置.?
最佳答案
  • 五星知识达人网友:第四晚心情
  • 2021-03-25 23:06
利用鼠标事件控制位置,比如:
private void butPlan_MouseMove(object sender, MouseEventArgs e)
{
//播放歌曲快进
if (e.Button == MouseButtons.Left && butPlay.BackgroundImage == FFS)
{
timer2.Enabled = false;
butPlan.Location = new Point(MousePosition.X - this.Location.X-10, prTime.Location.Y);
if ( butPlan .Location.X < 2 )
{
butPlan.Location = new Point(prTime.Location.X, prTime.Location.Y);
}
if (butPlan.Location.X > prTime.Size.Width -4)
{
butPlan.Location = new Point(prTime.Location.X + prTime.Size.Width - 4, prTime.Location.Y);
}
prTime.Value = (MousePosition.X - this.Location.X-3) * (prTime.Maximum / prTime.Size.Width)-6000;
TT((prTime.Value/1000).ToString ());
}
}

private void butPlan_MouseCaptureChanged(object sender, EventArgs e)
{
try
{
timer2.Enabled = true;
Music.CurrentPosition = prTime.Value / 1000;
MusicLrc.Text = "";
}
catch { }
}
全部回答
  • 1楼网友:末日狂欢
  • 2021-03-26 00:13
button1.Style.Add("position", "absolute");
button1.Style.Add("left", "0");
button1.Style.Add("top", "0");
其它样式以此方法都可以添加
  • 2楼网友:西岸风
  • 2021-03-25 23:46
webform的话,楼上已经写好了,
winform的话:
button1.Location = new Point(0, 0);
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯