Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 675281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:48:03+00:00 2026-05-14T00:48:03+00:00

I have a C# Winforms program with multiple textboxes. I used the properties for

  • 0

I have a C# Winforms program with multiple textboxes. I used the properties for each box to place text in them, explaining to the user what value goes in them. I want the text to highlight whenever a user selects that box. By either tabbing or mouse click. I won’t have to do this if there’s a way to display what value goes in the textbox somewhere outside of it.

I tried the Textbox.select method but it had no effect. The same with this.

Here’s a Screenshot of my program.

My Code:

    private void grapplingText1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
    {
        grapplingText1.SelectionStart = 0;
        grapplingText1.SelectionLength = grapplingText1.Text.Length;

Will this do, or is more required?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:48:03+00:00Added an answer on May 14, 2026 at 12:48 am

    How about you assign ToolTip to TextBox and put all the “talk what textbox is for” inside that?

    Just drag & drop ToolTip inside the Form. And then in each TextBox properties you should have additional entry in Misc section ToolTip on toolTip1 (or whatever it’s name will be if you rename it).

    Then when user hovers over TextBox (Read Only/Disabled TextBox doesn’t seems to display ToolTips) and stops there for 1 second ToolTip should show with proper info.

    You can eventually or even better have a Label next to TextBox saying what is is, but having a ToolTip is also a good idea to explain more information to user thru that.

    For doing stuff with WaterMark so you don’t have to go the long way by setting the events, taking care of SelectAll etc you could do it like this. Create new watermark.cs file and replace it with this code. Make sure you have changed namespace to match your program namespace.

    #region
    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    #endregion
    
    namespace Watermark {
        public static class TextBoxWatermarkExtensionMethod {
            private const uint ECM_FIRST = 0x1500;
            private const uint EM_SETCUEBANNER = ECM_FIRST + 1;
            [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
            public static void SetWatermark(this TextBox textBox, string watermarkText) {
                SendMessage(textBox.Handle, EM_SETCUEBANNER, 0, watermarkText);
            }
        }
    }
       internal class WatermarkTextBox : TextBox {
        private const uint ECM_FIRST = 0x1500;
        private const uint EM_SETCUEBANNER = ECM_FIRST + 1;
        private string watermarkText;
        public string WatermarkText {
            get { return watermarkText; }
            set {
                watermarkText = value;
                SetWatermark(watermarkText);
            }
        }
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
        private void SetWatermark(string watermarkText) {
            SendMessage(Handle, EM_SETCUEBANNER, 0, watermarkText);
        }
    }
    

    In your Form you activate it like this:

    textBoxYourWhatever.SetWatermark("Text that should display");
    

    It stays there as long the TextBox is empty. When users gets into TextBox text disappears. It appears again when TextBox is cleaned (either by user or automatically). No need for any special events etc.

    EDIT:

    I’ve added also internal class WaterMarkTextBox which gives you an option to simply use new WaterMarkTexBox that becomes available in Designer. Then drag and drop it to your designer and use it. It behaves like normal textbox just gives you additional field WaterMarkText.

    I still prefer the first method thou. Doesn’t make you rebuild your gui again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 369k
  • Answers 369k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One could use a BufferedImage with an image type that… May 14, 2026 at 6:16 pm
  • Editorial Team
    Editorial Team added an answer You can create a NSAttributedString from HTML. You then draw… May 14, 2026 at 6:16 pm
  • Editorial Team
    Editorial Team added an answer Managed to fix this by working some more on the… May 14, 2026 at 6:16 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.