labelTotal 保存类 Keypad (C# WinForms) 的值。ToString 已被覆盖以返回 labelTotal.Text。
namespace Gui3
{
public partial class Keypad : Form
{
public Keypad()
{
InitializeComponent();
}
public override String ToString() {return labelTotal.Text;}
private void buttonOk_Click(object sender, EventArgs e)
{
this.Close();
}
...
为什么 keypad.ShowDialog().ToString() 不返回 labelTotal.Text?
namespace Gui3
{
public partial class Setup : Form
{
public Setup()
{
InitializeComponent();
}
private void buttonStartDepth_Click(object sender, EventArgs e)
{
Keypad keypad = new Keypad();
////////// Not working as expected /////////
String total = keypad.ShowDialog().ToString();
...