【发布时间】:2015-02-18 02:26:45
【问题描述】:
这是我的代码,我试图在单击按钮后更改文本的颜色,但什么也没发生
我的颜色函数不明确,因为我使用的是 itextsharp 和 system.drawing 库...
我尝试使用下面的代码..虽然它没有给出错误但文本的颜色没有改变..我尝试使用clickedbutton。 Forecolor 功能也一样,但它仍然保持不变.. 这两个功能都不起作用
btn.ForeColor = System.Drawing.Color.Red;
clickedbutton.Forecolor= System.Drawing.Color.Red;
我想改变
下文本的颜色ClickedButton.Text="Input Processing"
任何意见都将受到高度赞赏。我知道这是一个非常愚蠢的问题,但我很困惑:(
我的代码是
private void btn_Preprocess_Click(object sender, EventArgs e)
{
Button clickedButton = (Button)sender;
clickedButton.Text = "Input Processing...";
btn_Preprocess.ForeColor = System.Drawing.Color.Red;
clickedButton.Enabled = false;
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
SourcePath = folderBrowserDialog1.SelectedPath;
string searchPattern = "*.*";
DirectoryInfo di = new DirectoryInfo(SourcePath);
GetFiles1(di, searchPattern);
MessageBox.Show("Process Complete");
}
【问题讨论】:
-
我不明白。您想使用 clickedButton 的文本“输入处理”更改按钮,但您的代码会更改 btn_Preprocess 的颜色...
-
你确定是asp.net而不是WinForms?
-
它是 WinForm 因为在 WPF 中是 Foreground 属性而不是 ForeColor
-
它的窗口形式.. LPs--兄弟我尝试使用 clickedbutton.forecolor=System.Drawing.Color.Red;但它不起作用......我什至删除了禁用属性但没有任何改变......