-1
我想將Keycode值保存到配置文件以在應用程序啓動時加載。 這是我的代碼。C#將KeyCode保存到配置文件
private void ButtonSelect_KeyDown(object sender, KeyEventArgs e)
{
buttonValue.Text += (char)e.KeyCode;
Keys main = e.KeyCode;
mainValue = main;
}
我從另一個表單讀取mainValue,我想將mainValue保存到配置文件。 非常感謝你!
提供的代碼讀取提供的代碼示例爲什麼一個配置文件?使用[應用程序設置](https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/using-application-settings-and-user-settings)。 –
什麼配置文件?無論如何,如果你覆蓋mainValue,那麼你有什麼相關性呢?你有什麼試圖做到這一點?本網站不應編寫完整的解決方案 - 您需要付出一些努力。 –
public partial class ButSelMain:Form { public static string ButMain; public static Keys mainValue; } 我想,當KeyDown顯示char label.text並將KeyCode保存到user.config 我已創建屬性設置,並保存所有應用程序的值,並正常工作。 我的問題是,我無法找到我如何保存e.Keycode值... 我嘗試將其保存爲Convert.ToString,Convert.ToInt .....但不工作。 我是新手編程,請顯示認識... 再次感謝您! – Maximvs