我一直在为我遇到的一个问题而烦恼(我刚开始用 C# 编码)
我有一个主屏幕(以下简称表格 1)和一个视频选项表格(以下简称表格 2)(包括图片)。现在,当我将 Form 2 中的 Radiobuttons 更改为“ Windowed ”并选择一个分辨率时,我希望在 Form 1 中更改一些选项。
到目前为止,这是我所获得的,它转到 Form 1 代码,但说我不能在那里改变任何东西。
代码片段主窗体
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnVideo_Click(object sender, EventArgs e)
{
Visual_Options options = new Visual_Options();
options.Show();
}
代码片段选项表单
public partial class Visual_Options : Form
{
frmMain Main;
public Visual_Options()
{
InitializeComponent();
}
private void Visual_Options_Load(object sender, EventArgs e)
{
switch (Main.FormBorderStyle) //Check the Borderstyle of frmMain with Switch to determine current state
{
case FormBorderStyle.None: // if BorderStyle of frmMain = "None"
if (Main.WindowState == FormWindowState.Maximized) //Check if frmMain = Maximizes
{
rbFullscrn.Checked = true;
}
else
{
rbBorderless.Checked = true;
};
break;
case FormBorderStyle.Fixed3D:
rbWindow.Checked = true;
break;
}
switch (Main.Width) //Check Width to determine current value
{
case 800:
rb8x6.Checked = true;
break;
case 1024:
rb10x7.Checked = true;
break;
case 1280:
rb12x7.Checked = true;
break;
}
}
private void btnAccept_Click(object sender, EventArgs e)
{
if (rbFullscrn.Checked == true)
{
Main.WindowState = FormWindowState.Maximized;
Main.FormBorderStyle = FormBorderStyle.None;
}
else if (rbBorderless.Checked == true && rb8x6.Checked == true)
{
Main.WindowState = FormWindowState.Normal;
Main.FormBorderStyle = FormBorderStyle.None;
Main.Height = 600;
Main.Width = 800;
}
else if (rbBorderless.Checked == true && rb10x7.Checked == true)
{
Main.WindowState = FormWindowState.Normal;
Main.FormBorderStyle = FormBorderStyle.None;
Main.Height = 768;
Main.Width = 1024;
}
else if (rbBorderless.Checked == true && rb12x7.Checked == true)
{
Main.WindowState = FormWindowState.Normal;
Main.FormBorderStyle = FormBorderStyle.None;
Main.Height = 720;
Main.Width = 1280;
}
else if (rbWindow.Checked == true && rb8x6.Checked == true)
{
Main.WindowState = FormWindowState.Normal;
Main.FormBorderStyle = FormBorderStyle.Fixed3D;
Main.Height = 600;
Main.Width = 800;
}
else if (rbWindow.Checked == true && rb10x7.Checked == true)
{
Main.WindowState = FormWindowState.Normal;
Main.FormBorderStyle = FormBorderStyle.Fixed3D;
Main.Height = 768;
Main.Width = 1024;
}
else if (rbWindow.Checked == true && rb12x7.Checked == true)
{
Main.WindowState = FormWindowState.Normal;
Main.FormBorderStyle = FormBorderStyle.Fixed3D;
Main.Height = 720;
Main.Width = 1280;
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
我现在在互联网上看了一会儿,我找到了一些解决方案,但是,从我找到的几个解决方案中,到目前为止似乎没有一个有效。
提前TY,
我^_^