Windows窗体列表框验证

编程入门 行业动态 更新时间:2024-10-28 11:31:15
本文介绍了Windows窗体列表框验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嘿伙计们,我有一个名为lst_Pending的Listbox,它有两个项目,True和False。列表框是表单的一部分,我需要在单击提交时如果您没有选择true或false,您将收到一条错误消息,询问您是否有必要选择一个。我从来没有真正使用过列表框,所以这就是我不确定的原因。 使用Listbox是否有更好的替代方法可用于真或假?

Hey guys, I've got a Listbox called lst_Pending and it has two items, True and False. The list box is a part of a form and I need to when submit is clicked if you haven't selected true or false you'll receive an error message asking you that it is necessary to pick one. I've never really used list boxes so this is why I'm not sure. Would there be any better alternatives to using a Listbox for something that's true or false?

推荐答案

试试这个列表框 Try this for listbox private void button1_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { //your code logic } else { MessageBox.Show("Please select anyone"); } }

更多推荐

Windows窗体列表框验证

本文发布于:2023-11-04 21:44:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559093.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   列表   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!