如何在组合框中隐藏选定的值 [英] How to hide Selected value in the combobox

查看:46
本文介绍了如何在组合框中隐藏选定的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在做schoolsoftware项目.用于分配时间表.我使用了
在datagridview的组合框中显示所有教师姓名.我想要什么
是用户是否从组合框中选择教师姓名并分配时间段.
在下一个单元格的组合框中不会显示相同的老师姓名
或者我需要显示一条消息,就像您已经选择了该名称一样.

如果有人有任何想法如何做对我有帮助

解决方案

很多方法:
1.创建一个没有选定教师的新教师集合,然后重新绑定下一个组合框.

2.在SelectedIndexChanged事件中,从其他ComboBox中删除相同的项.

3.创建教师集合作为字段.

 私有列表<老师> TeacherCollection = 列表< Teacher>(); 


在ListBoxes的SelectdIndexChangedEvent中:

 如果(teacherCollection.Select(t = >  t ==( (Teacher)((ComboBox)sender).SelectedItem)).Count()==  0 )
{
    TeacherCollection.Add((教师)((((ComboBox)sender).SelectedItem)));
}
其他
{
    MessageBox.Show(" );
} 


hi i am doing the schoolsoftware project.for allocating the timetable.i used
to display all the teachername in the combobox inside datagridview. what i want
is if the user select the teachername from the combobox and allocate the period.
the same teacher name will not going to display in the combobox in the next cell
or i need display a message like you have already selected this name.

if anyone have any idea how to do it help me

解决方案

many ways:
1. Create a new Collection of teachers without selected teachers then ReBind the next ComboBoxes .

2. In SelectedIndexChanged event, Remove the same Item from other ComboBoxes.

3. Create a Collection of teachers as a field.

private List<Teacher> teacherCollection = new List<Teacher>();


In SelectdIndexChangedEvent of ListBoxes:

if (teacherCollection.Select(t => t == ((Teacher)((ComboBox)sender).SelectedItem)).Count() == 0)
{
    teacherCollection.Add((Teacher)(((ComboBox)sender).SelectedItem));
}
else
{
    MessageBox.Show("Repetitious");
}


这篇关于如何在组合框中隐藏选定的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆