Winform控件相关收集

it2023-06-18  70

lable标签生成下划线

this.lbContinuousNote.Font = new Font(this.label1.Font.FontFamily, this.label1.Font.Size, FontStyle.Underline);

tableLayoutPanel设置特定行绝对行高

tableLayoutPanel1.RowStyles[1].SizeType = SizeType.Absolute; tableLayoutPanel1.RowStyles[1].Height = 0;

窗体位置和大小

private void Form1_Load(object sender, EventArgs e) { /* System.Windows.Forms.SystemInformation.WorkingArea.Width //屏幕宽度 System.Windows.Forms.SystemInformation.WorkingArea.Height //屏幕高度(去系统任务栏,当显示有任务栏的时候) this.Size.Width //自己窗体的宽度, this.Size.Width //自己窗体的高度 this.ClientRectangle.Width //工作区域宽度 this.ClientRectangle.Height //工作区域高度设置窗口初始位置 this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定 this.StartPosition = FormStartPosition.CenterParent; //窗体在其父窗体中居中 this.StartPosition = FormStartPosition.CenterScreen; //窗体在当前显示窗口中居中,尺寸在窗体大小中指定 this.StartPosition = FormStartPosition.WindowsDefaultBounds; //窗体定位在windows默认位置,边界也由windows默认决定 this.StartPosition = FormStartPosition.WindowsDefaultLocation; //窗体定位在windows默认位置,尺寸在窗体大小中指定 */ #region 居中显示 //int x = (System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) / 2; //int y = (System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height) / 2; //this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定 //this.Location = (Point)new Size(x, y); //窗体的起始位置为(x,y) #endregion #region 全屏显示 不包括任务栏、停靠窗口和停靠工具栏。 //Rectangle rect = Screen.GetWorkingArea(this);//工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 Point p = new Point(rect.Width, rect.Height); this.Size = new Size(p); this.Location = (Point)new Size(0, 0); 不包括任务栏、停靠窗口和停靠工具栏。 //var x = System.Windows.Forms.SystemInformation.WorkingArea.Width; //屏幕宽度 //var y = System.Windows.Forms.SystemInformation.WorkingArea.Height; //屏幕高度(去系统任务栏,当显示有任务栏的时候) //this.ClientSize = new System.Drawing.Size(x, y); //this.Location = (Point)new Size(0, 0); //全屏显示 this.FormBorderStyle = FormBorderStyle.None; //设置窗体边框样式 this.WindowState = FormWindowState.Maximized; //最大化窗体 #endregion } private void MinBtn_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; } private void NormalBtn_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Normal; } private void MaxBtn_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Maximized; } private void ExitBtn_Click(object sender, EventArgs e) { this.Close(); }
最新回复(0)