vb.net - 检查分组框内的多个控件类型是否为空并显示空控件的标签
问题描述
如前所述,我需要检查组框中的所有字段是否为空,然后显示一个消息框,显示空字段的标签。
问题是我在这个框中有多种类型的控件,包括:TextBox、NumericUpDown 和 DatePicker。
我想知道是否有比我在下面做的更简单的方法。
If BenchQtyCombo.Text = 1 Then
Dim B1emptyTextBoxes =
From txt In Bench1_Combo.Controls.OfType(Of TextBox)()
Where txt.Text.Length = 0
Select txt.Tag
Dim B1emptyNumericBox =
From num In Bench1_Combo.Controls.OfType(Of NumericUpDown)()
Where num.Value = 0
Select num.Tag
If B1emptyTextBoxes.Any Or B1emptyNumericBox.Any Then
MessageBox.Show(String.Format("Please Complete the Following Required Fields:" & vbCrLf & vbCrLf & "{0}", String.Join(", ", B1emptyTextBoxes, B1emptyNumericBox)))
End If
End If
我也有B1emptyTextBoxes, B1emptyNumericBox
在消息框中显示标签的问题,因为我得到这个字符串而不是标签
我还没有包含日期选择器的代码,这将类似于Where DatePicker.Date > Today
代码,直到我得到这个工作。
任何建议将不胜感激。
解决方案
您将加入 2 个列表以将它们显示在MessageBox
. 您需要单独加入这些列表的内容,然后加入这些字符串。
您的MessageBox
字符串将需要:
String.Join(", ", String.Join(", ", B1emptyTextBoxes), String.Join(", ", B1emptyNumericBox))
推荐阅读
- python-3.x - 如何在 python 中将 pandas DataFrame 转换为 YAML
- javascript - spec.type 必须在 react-dnd 中定义
- python - 停止打印 INFO:cmdstanpy:start chain 1, INFO:cmdstanpy:finish chain 1
- clickhouse - ClickHouse中如何实现漏斗分析
- javascript - 如何显示 select2 多选的单个文本显示值?
- php - 如何使用 PHP 获取脚本在 linux 系统上运行的处理器核心号(类似于 C 中的 sched_getcpu())
- asp.net-mvc - 合并两个 linq 结果并转换为 json 对象
- c# - 如何使用 EF 合并 id 中已存在的数据
- netsuite - Netsuite - 调度程序在某些时间间隔内未运行
- python - 如何检查 pandas 合并函数是否实际上合并了数据,而不是用 nan 返回一整列?