如何处理组合框选择指数变化? [英] How can I handle ComboBox selected index changing?

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

问题描述

我有一个组合框有制造商的列表。当用户选择的生产,下面的网格填充了对于所选择的制造商的数据。该数据可被修改。用户必须preSS保存按钮所有的改变都完成后。

I have a ComboBox that have a list of manufacturers. When a user selects a manufacturer, a grid below is populated with data for the chosen manufacturer. That data can be modified. The user has to press the Save button after all changes are done.

但用户可以忘了preSS保存并选择从ComboBox其他制造商和电网将填充另一个数据,所以previous更改将丢失。

But the user can forget to press Save and select another manufacturer from the ComboBox and the grid will be populated with another data, so previous changes will be lost.

所以,我要问的用户,如果他想选择其他厂商之前保存更改。

So I need to ask user if he wants to save changes before selecting another manufacturer.

我怎样才能做到这一点?或者,也许你提供解决我的任务的另一种方式(从另一个角度看)?

How can I do this? Or maybe you offer another way of solving my task (looking from another angle)?

推荐答案

您应该处理ComboBox.SelectedIndexChanged事件。是这样的:

You should handle the ComboBox.SelectedIndexChanged event. Something like:

this.ComboBox1.SelectedIndexChanged += new system.EventHandler(ComboBox1_SelectedIndexChanged);

然后 ComboBox1_SelectedIndexChanged()只要稍有改变,你可以更新的功能,你的品牌信息会被调用。保存填充新的信息之前,旧的信息。或者提示用户,如果他们真的想在保存前改变它。

Then ComboBox1_SelectedIndexChanged() will be called whenever it changes and you can update your manufacturer info in that function. Save the old info before populating the new info. Or prompt the user if they really want to change it before saving.

这篇关于如何处理组合框选择指数变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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