【发布时间】:2020-05-26 09:35:07
【问题描述】:
当没有在任何文本框中输入文本时,我希望打开一个新表单,其中包含一条消息
if (rectangleBox.Checked == true && (int.Parse(side_a.Text) > 0 &&
int.Parse(side_b.Text) > 0))
{
var drawRectangle = new Rectangles(70 + int.Parse(side_a.Text),
80 + int.Parse(side_b.Text),
50 + int.Parse(side_a.Text), 70 + int.Parse(side_b.Text));
Figures.Add(drawRectangle);
};
if (string.IsNullOrWhiteSpace(side_a.Text) &&
string.IsNullOrWhiteSpace(side_b.Text) &&
string.IsNullOrWhiteSpace(side_c.Text))
{
Form1 form1 = new Form1();
Form1.ShowDialog();
}
但我在以下几行中遇到错误
if (rectangleBox.Checked == true && (int.Parse(side_a.Text) > 0 &&
int.Parse(side_b.Text) > 0))
"System.FormatException: '输入字符串的格式不正确。'"
【问题讨论】:
-
这能回答你的问题吗? Check Whether a TextBox is empty or not 完全相同的副本
-
“标记为空”是什么意思??
-
@Taw 当 TextBoxes 中没有文本时
-
人们试图帮助你,但你真的很难! “标记”是什么意思???另外:“没有文字”或没有有效数字“?一个或所有盒子中也缺少数据? - 一般规则,除非你不能清楚地表达你的目标,否则你不能为它编写代码..