AcceptsReturn 相当于 WebBrowser .NET 控件
我有一个 Windows .NET 应用程序,其中一个窗体有一个 WebBrowser 控件、一个“确定”按钮和一个“取消”按钮。
WebBrowser 控件托管一个 TextArea html 元素,因此我可以在其中写入。
如果“确定”按钮是表单的 AcceptButton (form.AcceptButton = btnOk),那么当我按 Enter 时,表单将捕获该事件,并且不会在我的 TextArea 中添加新行。
TextBox 有一个属性 AcceptsReturn 完全可以满足我的需要,但 WebBrowser 控件没有类似的属性。
如果承载 Web 浏览器的表单有 AcceptButton,关于如何保留 TextArea 的 Enter 事件有什么想法吗?
谢谢。
I have a Windows .NET application and one of the forms has a WebBrowser control, an OK button and a Cancel button.
The WebBrowser control hosts a TextArea html element, so I can write inside.
If the OK button is the form's AcceptButton (form.AcceptButton = btnOk) then when I press Enter the event is captured by the form, and no new line is added in my TextArea.
TextBox has a property AcceptsReturn that does exactly what I would need, but there is no similar property for WebBrowser control.
Any ideas on how to retain the Enter event for the TextArea if the form which hosts the WebBrowser has an AcceptButton?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您必须关闭表单上的 AcceptButton,而 TextArea 具有焦点才能使其工作。当 WebBrowser 控件内部发生某些特定情况时,您的窗体无法“知道”它不应该响应 Enter 键。
I think you'd have to turn off the AcceptButton on your form while the TextArea has the focus in order for this to work. Your form has no way of "knowing" that it's not supposed to respond to the Enter key while something in particular is going on inside the WebBrowser control.