![](/img/trans.png)
[英]how to check whether a button is clicked, inside another button click event in windows form application in C#
[英]How to run another windows form on button click in windows form application
我正在Windows窗體應用程序上工作,我需要根據用戶提供的許可證密鑰來升級Windows窗體應用程序軟件解決方案。假設他已將其軟件從基本版本升級到更高版本,在這種情況下,我們希望他輸入升級后的版本。許可證密鑰,將從我們的中央服務器進行驗證,並且軟件將升級。 為了升級軟件,我需要更改主類程序文件。
這是程序文件的代碼。
namespace UpgradeECV
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
現在,只要用戶eneters我想要正確的驗證的升級許可證密鑰
Application.Run(new Form1());
更改為
Application.Run(new Form2());
這怎么可能..請幫助我
通過使用指示用戶是否已獲得許可的簡單bool
標志,您可以Run
Form1
或Form2
,如下所示:
Form form = isLicensed ? new Form2() : new Form1();
Application.Run(form);
在這種情況下,除了運行Form1()類之外,您還可以運行其他一些類,在該類中您將比較版本並確定需要打開哪個Form。
假設版本是XX,則可以打開第一個表格,否則打開第二個表格。 這樣您就可以實現此目的,但是我看不到更改代碼運行時間的任何可能性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.