[英]in c#, how can you disable a button after the 1st click, and enable it again after you click another button?
我不能弄清楚我正在用c#在Visual Basic中制作Windows窗體應用程序,我有一個掃描按鈕,它會掃描文件夾中的所有內容並列出列表框中的所有文件
如果您再次單擊它,文件列表將再次出現,如何制作它,因此您只能按一次掃描按鈕,然后如果您單擊瀏覽按鈕,則可以再次按它?
瀏覽按鈕是選擇要掃描的文件夾
謝謝
這很瑣碎
private void ScanButtonClick(object sender, EventArgs e)
{
// do something
(sender as Button).Enabled = false;
}
private void BrowseButtonClick(object sender, EventArgs e)
{
ScanButton.Enabled = true;
}
不清楚是使用C#還是vb.net編寫,但由於該問題被標記為C#...
private void btnScan_Click(object sender, EventArgs e) {
btnScan.Enabled = false;
// other code here
}
private void btnBrowse_Click(object sender, EventArgs e) {
btnScan.Enabled = true;
//other code here
}
我在C#的Windows窗體應用程序中嘗試了此操作,效果很好!
private void button3_Click_1(object sender, EventArgs e)
{
int count = 0;
count++;
//add your code here
if (count == 1) {
button3.Enabled = false;
//only one click allowed
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.