Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
How to add cue banner or hint to UltraTextEditor
posted

I would like to add placeholder text similar to what you see on HTML Inputs.  I am using Net Advantage 2008 v1 in Visual Studio 2010, targeting 3.5.  I can do this with standard Windows Controls with the following:

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        CueProvider.SetCueText(TextBox1, "blah")
        CueProvider.SetCueText(TextBox2, "blahblah")
        CueProvider.SetCueText(UltraTextEditor1, "InfraCool") 'Does not work
        CueProvider.SetCueText(UltraTextEditor2, "UltraCool") 'Does not work
    End Sub

 

This is in a separate class:

Imports System.Runtime.InteropServices

Public Class CueProvider
    Private Const EM_SETCUEBANNER As Integer = &H1501

    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
    Private Shared 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

    Public Shared Sub SetCueText(ByVal control As Control, ByVal text As String)
        SendMessage(control.Handle, EM_SETCUEBANNER, 0, text)
    End Sub
End Class

Textbox1 and TextBox2 are just standard Winforms textbox controls.  UltraTexteditor1 and UltraTextEditor2 are Infragistics UltraTextEditors.  The first two controls behave as expected, the Infragistics editors show no cue banner.  I know there are other ways to override the class and set and remove the "placeholder" text, but I've already got a thousand of these in my app.  Is there another property to use, or does this function appear in later releases?

Thank you for your time and attention to this.

 

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    I'm not familiar with the EM_SETCUEBANNER message. I've never used it. I looked it up on MSDN and it says that this is supposed to work on an "edit control". I'm not entirely sure what that means or it has any significance. Does Windows look for certain types of controls, maybe? If so, then this obviously won't work on anything except the standard DotNet controls that are wrappers for window classes like TextBox.

    Have you tried this on any other controls? Does it work on a Label control, for example?

    According to MSDN, the SendMessage call will return true or false if the message succeeds or fails, respectively. Have you checked the return value to see if it thinks it was successful?

Children