c#中如何改变控件位置.?
privatevoidForm1_Load(objectsender,EventArgse){button1.Location.X=0;button1.Location....
private void Form1_Load(object sender, EventArgs e)
{
button1.Location.X = 0;
button1.Location.Y = 0;
这样怎么会不行.? 展开
{
button1.Location.X = 0;
button1.Location.Y = 0;
这样怎么会不行.? 展开
3个回答
展开全部
利用鼠标事件控制位置,比如:
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 { }
}
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 { }
}
展开全部
webform的话,楼上已经写好了,
winform的话:
button1.Location = new Point(0, 0);
winform的话:
button1.Location = new Point(0, 0);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
button1.Style.Add("position", "absolute");
button1.Style.Add("left", "0");
button1.Style.Add("top", "0");
其它样式以此方法都可以添加
button1.Style.Add("left", "0");
button1.Style.Add("top", "0");
其它样式以此方法都可以添加
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询