自定义控件、用户定义控件,方便用户定义功能强大的控件。
Control属性:
Size,BackGround,Location等属性
Control方法:
鼠标事件继承了System.Windows.Form.Control
自定义了一个视频播放的窗口控件:
Code
private void UpdateVisiblity()
{
if(dvrVisible)
{
for (int i = 0; i < MaxClos;i++ )
{
videowindows[i].Visible = (i<cols);
}
}
}
private void UpdateSize()
{
int width, height;
//width = (ClientRectangle.Width / cols) - 4;
//height = (ClientRectangle.Height ) - 4;
width = this.Size.Width / cols - 4;
height = this.Size.Height - 4;
// starting position of the view
int startX = (ClientRectangle.Width - cols * (width + 4)) / 2;
int startY = (ClientRectangle.Height -(height + 4)) / 2;
//int startX = 2;
//int startY = 2;
this.SuspendLayout();
for (int i = 0; i < cols; i++)
{
videowindows[i].Location = new Point(startX + (width + 4) * i + 1, startY+1);
videowindows[i].Size = new Size(width , height );
}
this.ResumeLayout(false);
}
问题:窗口不能充满容器