C# 组合框值更改,我应该使用什么事件来编写更新注册表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1066057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 07:23:36  来源:igfitidea点击:

C# Combo box value change, what Event should I use to write update the registry?

c#combobox

提问by

I have a read only combo-box with 5 values in, when the user selects a new value what event should I use to write that value to the registry?

我有一个包含 5 个值的只读组合框,当用户选择一个新值时,我应该使用什么事件将该值写入注册表?

Thanks

谢谢

采纳答案by Quintin Robinson

Well regardless of what you will end up doing with the value when selected, it is safe to use the SelectionChangeCommittedevent.

好吧,无论您最终会使用该值做什么,都可以安全地使用该SelectionChangeCommitted事件。

Here is a little follow up info on this event vs the other commonly used events. (from MSDN)

以下是有关此事件与其他常用事件的一些后续信息。(来自 MSDN)

SelectionChangeCommitted is raised only when the user changes the combo box selection. Do not use SelectedIndexChanged or SelectedValueChanged to capture user changes, because those events are also raised when the selection changes programmatically.

SelectionChangeCommitted 仅在用户更改组合框选择时引发。不要使用SelectedIndexChanged或SelectedValuechanged来捕获用户更改,因为在编程方式更改时也会提出这些事件。

回答by Patrick

I usually use the SelectedIndexChangedevent to check when a user selects a value in a combobox

我通常使用该SelectedIndexChanged事件来检查用户何时在组合框中选择了一个值

回答by John

How about if you are using the DateTimePicker? This does not have the SelectionChangeCommitted value.

如果您使用的是 DateTimePicker 呢?这没有 SelectionChangeCommitted 值。