无法为 kryptontextbox 设置 cuebanner
cannot set cuebanner for kryptontextbox
我尝试使用以下代码为 kryptontextbox 设置提示横幅
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SetCueText(KryptonTextBox1.Handle, "Enter Name here")
End Sub
End Class
Public Module CueBannerText
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As Int32
End Function
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Private Const EM_SETCUEBANNER As Integer = &H1501
Public Sub SetCueText(hWnd As IntPtr, text As String)
if Not hWnd = IntPtr.Zero Then
SendMessage(hWnd, EM_SETCUEBANNER, 0, text)
End If
End Sub
End Module
但是,文本未设置。我该如何解决这个问题
EM_SETCUEBANNER
适用于 TextBox
控件。 KryptonTextBox
实际上是一个包含 TextBox
的复合 Control
。
TextBox
使用 TextBox
属性 公开。您可以使用 KryptonTextBox1.TextBox.Handle
发送 EM_SETCUEBANNER
消息。
要查看组件的源代码,请查看此 GitHub repository。这是代码的相关部分:
public class KryptonTextBox : VisualControlBase, IContainedInputControl
{
//...
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(false)]
public TextBox TextBox
{
get { return _textBox; }
}
//...
}
我尝试使用以下代码为 kryptontextbox 设置提示横幅
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SetCueText(KryptonTextBox1.Handle, "Enter Name here")
End Sub
End Class
Public Module CueBannerText
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As Int32
End Function
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Private Const EM_SETCUEBANNER As Integer = &H1501
Public Sub SetCueText(hWnd As IntPtr, text As String)
if Not hWnd = IntPtr.Zero Then
SendMessage(hWnd, EM_SETCUEBANNER, 0, text)
End If
End Sub
End Module
但是,文本未设置。我该如何解决这个问题
EM_SETCUEBANNER
适用于 TextBox
控件。 KryptonTextBox
实际上是一个包含 TextBox
的复合 Control
。
TextBox
使用 TextBox
属性 公开。您可以使用 KryptonTextBox1.TextBox.Handle
发送 EM_SETCUEBANNER
消息。
要查看组件的源代码,请查看此 GitHub repository。这是代码的相关部分:
public class KryptonTextBox : VisualControlBase, IContainedInputControl
{
//...
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(false)]
public TextBox TextBox
{
get { return _textBox; }
}
//...
}