C#-comboBox选定的IndexChange [英] C# -comboBox Selected IndexChange

查看:96
本文介绍了C#-comboBox选定的IndexChange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ComboBox,其中包含EmpolyeeNames列表。当用户选择EmpolyeeName e1时,下面的列表框将填充所选雇员的数据。该数据可以修改。用户并必须在完成所有更改后按保存按钮。

I have a ComboBox that have a list of EmpolyeeNames. When a user selects a EmpolyeeName "e1", a ListBox below gets populated with data for the chosen employee. That data can be modified. The user and has to press the Save button after all changes are done.

但是如果用户忘记按保存并从ComboBox中选择另一个雇员,则说 e2,在这里,我问用户mEssagebox您是否要为员工 e1
保存数据,如果是,那么我要保存特定员工 e1的数据,

But if the user forgets to press Save and select another employee from the ComboBox say "e2" , here i ask user mEssagebox "Do you want to save data for employee "e1" if yes then I save the data of particular employee "e1",

但是在保存数据的同时,组合框索引也发生了更改,其文本显示了最近选择的员工 e2,但数据来自员工 e1。

But here while saving the data combo box index gets changed and its text show recently selected employee "e2", but the data is of employee "e1".

我怎么能

推荐答案

很简单,当组合框出现时,保留comboBox中的loyerye以前的旧文本,直到保存完成。

Quite simply, when the combobox item is selected put the employee into a class variable. Use this class variable instead of the item in the combobox.

在保存(或提示)用户后,您可以将雇员放入一个类变量中,而不使用组合框中的项目。然后将变量设置为新选择的项目。

After you have saved (or prompted) the user you can then set the variable to the newly selected item.

这篇关于C#-comboBox选定的IndexChange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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