我对来自 VB6 的 C# 编程相当陌生,所以请温柔:P
我一直在使用面板对控件进行分组(即面板包含文本框、标签、列表视图等),然后让面板在运行时自行对齐,以便控件以不同的分辨率对齐。但是,我是从面板的 Paint 例程中执行此操作的(?)
IE:
private void pnlTop_Paint(object sender, PaintEventArgs e)
{
btnExit.Location = new Point(this.Width - (this.Left + lblTitleMain.Left + btnExit.Width), 10);
btnMinimize.Location = new Point(this.Width - (this.Left + lblTitleMain.Left + (btnExit.Width * 2)), 10);
btnSettings.Location = new Point(this.Width - (this.Left + lblTitleMain.Left + (btnExit.Width * 2 + btnExit.Width)), 10);
lblTitleMain.Left = (((this.ClientSize.Width - lblTitleMain.Width) / 2) / 2) / 2;
lblTitleMain.Top = btnExit.Top + lblTitleMain.Height;
int intMenuY = lblTitleMain.Bottom + 5;
lnkMenuSystem.Location = new Point(lblTitleMain.Left + 3, intMenuY);
lnkMenuDeployment.Location = new Point(lnkMenuSystem.Right + 50, intMenuY);
lnkMenuTables.Location = new Point(lnkMenuDeployment.Right + 50, intMenuY);
lnkMenuTCP.Location = new Point(lnkMenuTables.Right + 50, intMenuY);
lnkMenuDCM.Location = new Point(lnkMenuTCP.Right + 50, intMenuY);
lnkMenuProcessData.Location = new Point(lnkMenuDCM.Right + 50, intMenuY);
lnkMenuGenerateReports.Location = new Point(lnkMenuProcessData.Right + 50, intMenuY);
lineMenuButtom.StartPoint = new Point((((this.ClientSize.Width - lblTitleMain.Width) / 2) / 2) / 2, lnkMenuSystem.Top + lnkMenuSystem.Height + 10);
lineMenuButtom.EndPoint = new Point(this.Width - (this.Left + lblTitleMain.Left), lnkMenuSystem.Top + lnkMenuSystem.Height + 10);
lnkMenuErrorMessage.Location = new Point(lnkMenuSystem.Left, lineMenuButtom.Y1+5);
lnkMessageWelcome.Location = new Point(lineMenuButtom.X2 - lnkMessageWelcome.Width, lineMenuButtom.Y2 + 5);
GlobalVariables.intGeneralLeft = lineMenuButtom.StartPoint.X;
GlobalVariables.intGeneralWidth = lineMenuButtom.X2;
}
我想问的是: 这是正确的方法吗?
这样做的原因是因为我不确定一旦应用程序在旧系统上运行这是否会影响性能(假设它将在 XP 中使用 2g RAM Pentium 4 HT 或同等系统)。