C# - 在组合框可见之前填充哪个事件?
我目前正在点击更新它,但这会导致用户能够看到重新填充的发生。我可以使用哪些其他事件来让我自己处理它,然后在我准备好时显示组合框? (人口之后)
I'm currently updating it on click, but this results in the user being able to see the repopulation occur. Which other event can I use which will allow me to handle it myself, then show the combobox when i'm ready? ( after population)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道您正在开发什么,但是该组合框可能位于窗口左右,并且会显示一个触发的事件。使用该事件填充组合框。
[编辑] Ah Winforms。使用加载事件。
[edit2] 每次点击时呃。
好吧。我发现了一个肮脏的解决方案,建议您重写 WndProc 并捕获消息,但我认为最好继承组合框并重写 OnDropDown 以在调用祖先的 OnDropDown 方法之前执行填充。
您也应该在输入时填充该框,因为可以使用键盘(箭头)选择一个值,甚至无需下拉该框。如果您希望在每个选择上都使用它,则需要两者,因为只有当该框之前没有焦点时,单击才会引发 Enter 事件。
I don't know what you're developing, but that combobox is probably on a window or so that will have an event that fires on show. Use that event to populate the combobox in.
[edit] Ah Winforms. Use the Load event.
[edit2] On each click eh.
Alright. I found a dirty solutions that advises you to override the WndProc and capture messages, but I think it's better to inherit the combobox and override OnDropDown to perform you populating before calling the ancestor's OnDropDown method.
You should populate the box when entered too, because a value may be selected using the keyboard (arrows) without even dropping down the box. You'll need both if you want it on each selection, because a click only causes the Enter event when the box didn't have focus before.
您是否尝试过ComboBox.DropDown 事件?
Have you tried the ComboBox.DropDown Event?
您可以尝试在更新之前调用 SuspendLayout() 并在更改后调用 ResumeLayout() 。
You could try to call SuspendLayout() before updating and calling ResumeLayout() after the changes.
加载表单时创建控件后,combobox.add_HandleCreated 会触发
combobox.add_HandleCreated triggers after the control is created as the form is loading