|
VS2019 C#明明设置了将上方按钮设为可用却不行
图片:
javascript:;
代码:
Form1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
button1.Text = "更改背景颜色";
button2.Text = "打开进度条窗口";
}
private void button1_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
this.BackColor = colorDialog1.Color;
}
}
private void button2_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.Show();
}
}
}
Form2:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void Form2_Load(object sender, EventArgs e)
{
button1.Text = "关闭";
button2.Text = "启动上方按钮";
button3.Text = "禁用上方按钮";
}
private void button2_Click(object sender, EventArgs e)
{
button1.Enabled = true;
this.Refresh();
}
private void button1_Click_1(object sender, EventArgs e)
{
Close();
}
private void button3_Click(object sender, EventArgs e)
{
button1.Enabled = false;
this.Refresh();
}
}
}
|
-
上一篇: Windows api如何调整窗口大小下一篇: 无法打开内存
|