code-tutorial.com

The best resources for developers

Showing a hint for a C# winforms edit control. For example a C# Winform editor is needed for it's edit control.

TextInput myInput;
boolean showingHint = true;

myInput.text = "Search Terms";
myInput.color = 0xcccccc;

myInput.onFocusGained = function() {
  if(showingHint) {
    myInput.text = "";
    myInput.color = 0x000000;
    showingHint = false;
  }
}

myInput.onFocusLost = function() {
  if(!showingHint && myInput.text.length == 0) {
    myInput.text = "Search Terms";
    myInput.color = 0xcccccc;
    showingHint = true;
  }
}

Tags: c# user-interface winforms

Source: By Andrew as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5


Related code-snippets: