System.Windows.Controls.TextBox Handle(System.Windows.Controls.TextBox 句柄)
问题描述
我觉得我在这里遗漏了一些非常明显的东西.
I feel like I'm missing something really obvious here.
我知道表单通常具有 Handle 属性,但我使用的是 System.Windows.Controls.TextBox 并且它没有 Handle 属性.
I know that forms in general have a Handle property, but I am using a System.Windows.Controls.TextBox and it does not have a Handle property.
如何访问 TextBox 的句柄?我注意到 RichTextBox 具有 Handle 属性,那么为什么不是常规的 TextBox?
How do I access the TextBox's handle? I noticed that RichTextBox has the Handle property, so why not the regular TextBox?
推荐答案
你可以调用 句柄 在文本框上.它是从 System.Windows.Forms.Control 继承的属性.
You can just call Handle on the TextBox. It is an inherited property from System.Windows.Forms.Control.
问题已更新为询问 WPF
WPF 不像典型的 Win32 应用程序或 WinForms 应用程序那样使用句柄.每个控件在 WPF 中都不是它自己的窗口.您可以使用 Spy++ 验证这一点,它无法区分每个控件.因此,您不能像使用 WinForms 和 Win32 应用程序那样向单个控件发送消息.
WPF doesn't use handles like a typical Win32 application or WinForms application. Each control is not its own Window in WPF. You can verify this with Spy++, it cannot differentiate between each control. Therefore you cannot SendMessage to the individual controls like you can with WinForms and Win32 apps.
您可以使用 WindowInteropHelper 来获取WPF 窗口的父窗口句柄.
You can use WindowInteropHelper to get the parent window handle of a WPF window.
这篇关于System.Windows.Controls.TextBox 句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:System.Windows.Controls.TextBox 句柄
基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
