如何在wpf中循环遍历多个组合框以获取初始值 [英] How to loop through multiple comboboxes for initial value in wpf
本文介绍了如何在wpf中循环遍历多个组合框以获取初始值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
任何人都可以告诉我如何循环添加在表单网格上的多个组合框架&检查wpf中的初始值。如果任何组合框的初始值为null,那么我应该弹出一条消息。
我试过这个,但是我在foreach表达式中得到错误:
Hi all,
Can anybodytell me how to loop through multiple comboboxes added on a form grid & check for their initial values in wpf. If the initial value of any of the combobox is null then i should pop up a message.
I tried this, but i get error in the foreach expression:
foreach (Control c in this.Controls)
{
if (c is ComboBox)
{
ComboBox textBox = c as ComboBox;
if (textBox.SelectedValue == null)
{
MessageBox.Show("please fill all fields");
break;
}
}
}
提前谢谢。
Thanks in advance.
推荐答案
我想这会对你有帮助。
http://dirk.schuermans.me/?p=585 [ ^ ]
I think this will help you.
http://dirk.schuermans.me/?p=585[^]
这篇关于如何在wpf中循环遍历多个组合框以获取初始值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文