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 { }
}
每个控件都有一个Anchor属性,他可以分别锁定控件与窗体Top, Bottom, Left, Right边的距离,效果你自己试试。还有一种方法可以自己写,在窗体的SizeChanged事件中求得窗体size(即 Height,Width属性)变化前后的比例,然后再按照这个比例改变控件的Location就可以了。 你想要什么样的效果用这个方法,我想都行吧,可以找我。
我是新手只想到这个了,嘿嘿,有高手解答的话,我正好的学习..
控制控件的Location属性啊.比如有个固定的textBox1
TextBox dynTextBox1 = new TextBox()
dynTextBox1.Location = new Point(textBox1.Location.X,textBox1.Location.Y+15)//X坐标不变,Y坐标加15
TextBox dynTextBox2 = new TextBox()
dynTextBox2.Location = new Point(dynTextBox1.Location.X,dynTextBox1.Location.Y+15))//X坐标不变,Y坐标加15
this.panel1.Controls.Add(dynTextBox1)
this.panel1.Controls.Add(dynTextBox2)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)