0

This answer shows how to use a cuebanner with a textbox. The content for the label is for each textbox the same. A comment on that answer states that you can use attached properties to increase style re-usability and includes a link to C# code.

I'm able to write/read C# but unfortunately I don't understand what the code does. I also have done some searching for attached properties but I really don't get how I can change the displayed text so it reusable.

Could anyone give me an example how I do this in VB.NET or link me some sites that explain how it's done?

Community
  • 1
  • 1
Krowi
  • 1,565
  • 3
  • 20
  • 40
  • As stated in your other question, you seem to be after a *watermark `TextBox`*... there are many ways of creating these and you can find what they are in the [Watermark / hint text TextBox in WPF](http://stackoverflow.com/questions/833943/watermark-hint-text-textbox-in-wpf) question... I believe that you'll find that some at least, are better solutions than your proposed solution (from the linked question). If you want it in VB, then just convert it in an online VB to C# converter, like [Developer Fusion](http://www.developerfusion.com/tools/convert/csharp-to-vb/). – Sheridan Feb 27 '14 at 21:28
  • Thank you for the links. I definitely gonna try em out and post an update if I succeed or not. – Krowi Feb 27 '14 at 21:32
  • Can't fail... try the answer with the most votes first. I use a similar method and it works great. I can use it just like this: `` – Sheridan Feb 27 '14 at 21:44
  • My WPF knowledge isn't good enough to write a whole bunch of code I won't understand anyways but the link you gave was useful after all. Somewhere in that question someone mentioned http://wpftoolkit.codeplex.com. I tried it out and it does what I needed in an easy way. So thank you for the link :) – Krowi Feb 28 '14 at 02:18

1 Answers1

0

This will give you watermark text on your textbox controls:

Imports:

Imports System.Runtime.InteropServices

Global Declarations in your main class:

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

Functions in your main class:

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

Usage (usually in form_load event):

SetCueText(TextBox1, "blah")
SetCueText(TextBox2, "blahblah")

Is this what you meant?

Hope this helps :)

Jack Pollock
  • 344
  • 1
  • 13