private void Button_Click(object sender, RoutedEventArgs e) { int id; if (int.TryParse(StockID.Text, out id) == false) { MessageBox.Show("错误的股票编号输入\n请输入纯数字编号"); return; } StockInfo dlg = new StockInfo(); dlg.StockID = StockID.Text; dlg.Show(); }