当数据更改时,刷新组合框的首选方法是什么? [英] What is the preferred method of refreshing a combo box when the data changes?

查看:186
本文介绍了当数据更改时,刷新组合框的首选方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当数据更改时,刷新组合框的首选方法是什么?



如果窗体已打开且组合框数据已加载,刷新组合框的内容,而不必关闭窗体并重新加载?



您必须在组合框上的Click事件上执行某些操作吗?

解决方案

您必须确定:



1)您的数据何时更改?



如果它取决于其他用户的活动,因此您无法确定它是否更改没有查询DB,您可以找出刷新的最佳时间,如表单加载或每次点击,或者您可以使用定时器控件在特定时间刷新数据。



2)您的用户何时需要了解此更改?



尝试了解用户了解更改的紧急程度。与他们交谈。根据具体情况,您可以决定何时刷新您的数据。



最后:



没有正确的方法。这取决于软件结构,用户的需求和具体情况。



希望它有帮助。好运!



更新:



我可以添加解决方案,最近使用。如果有什么不清楚,只需问一下。



我假设你从 MS SQL Server 刷新组合。



如果是这样,



1。创建表格,数据更改日期或版本。



2。 onClick事件或使用计时器控件,每5分钟(或任何其他时间)检查更改,更改您的组合的日期(或版本)与上次更新(或版本)的表中的最后一个日期(或版本),并且只有日期(或版本)更改,刷新组合。



3。可以存储在变量或文本框控件中的最后日期(或版本),每次刷新组合。



4。如果数据更改,请更新该表中的最后一个日期(或版本)。



在这种情况下,您只需检查更改,而不更新它们。



PS 如果这个解决方案不适合你,只需刷新每次点击事件。对于这种情况没有更好的事件。


What is the preferred method of refreshing a combo box when the data changes?

If a form is open and the combo box data is already loaded, how do you refresh the contents of the combo box without the form having to be closed and reloaded?

Do you have to do something on the Click event on the combo box? This would seem to be a potential slow down for the app if there is a hit to the database every time someone clicks on a combo box.

解决方案

You must determine:

1) When does you data change?

If it depends on other users activity, so you can't determine whether it's changed without querying DB, you can figure out an optimal time for a refresh, like form loading or on every click, or you can use a timer control to refresh the data in a specific time.

2) When does your user need to know about that change?

Try to understand how urgent it is for the user to know about a change. Talk to them. Depending on that, decide when do you need to refresh your data.

Finally:

There isn't a correct way of doing that. It depends on a software structure, users' needs and on a specific situation.

Hope it helps. Good Luck!

UPDATE:

I can add a solutions, that I used recently. If something won't be clear, just ask.

I assume, your refreshing the combo from MS SQL Server.

If so,

1. Create a table , storing in it Combo's data changing date or a version.

2. onClick event or using timer control, which will check for changes every 5 minutes(or any other time), you can compare last change date (or version) of your combo with last change(or version) in that table we store last date(or version) and only if the date(or version) was changed, refresh the combo.

3. Last date (or version) you can store in a variable or in a textbox control, changing it's value every time you refresh the combo.

4. Update last date(or version) in that table if the data changes.

In this case, you'll just need to check for changes, not update them.

P.S. If this solution doesn't feet you, just refresh every time on click event. There's no better event for that case.

这篇关于当数据更改时,刷新组合框的首选方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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