none
How to add tool tip in textbox in win form C# RRS feed

  • Question

  • i am using metro framework text box.

    I want to set tool tip while end user mouse hover of the textbox.

    normally, i am using textbox to browse the excel/mdb file to browse and display the file 
    insdie the textbox.

    The important thing is, i don't want to display full path in the text box.

    but, while mouse hover or mouse move in the text box, we jsut want to show the full path.

    Is there any way to do in .NET controls specially for textbox..?

    Wednesday, February 26, 2020 6:20 AM

Answers

  • Hi Gani tpt,
    You can subscribe to the textBox_MouseHover event by following the steps:
    1.Right click the textBox> Properties> Click the Events label > Choose the MouseHover
    And then you can use ToolTip.SetToolTip(Control, String) method to associate ToolTip text with the specified control.
    Here is a simple code example you can refer to.

    private void textBox1_MouseHover(object sender, EventArgs e)
    {
        toolTip1.SetToolTip(textBox1, "fullpath");
    }

    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Gani tpt Wednesday, February 26, 2020 8:36 AM
    Wednesday, February 26, 2020 8:12 AM

All replies

  • Not sure I understood your problem as there is no difficulty to add a Tooltip to a control :

    How to: Set ToolTips for controls on a Windows Form at design time

    Wednesday, February 26, 2020 6:31 AM
  • Hi Gani tpt,
    You can subscribe to the textBox_MouseHover event by following the steps:
    1.Right click the textBox> Properties> Click the Events label > Choose the MouseHover
    And then you can use ToolTip.SetToolTip(Control, String) method to associate ToolTip text with the specified control.
    Here is a simple code example you can refer to.

    private void textBox1_MouseHover(object sender, EventArgs e)
    {
        toolTip1.SetToolTip(textBox1, "fullpath");
    }

    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Gani tpt Wednesday, February 26, 2020 8:36 AM
    Wednesday, February 26, 2020 8:12 AM
  • Above image is my windows form.

    whenever i am clicking the browse button, i am fetching document from somewhere in the server and display in the textbox. 

    Here i am displaying only the file name, not the entire path.

    But, when end user mouse hover in the text box, it should display the entire path.

    my full path is : \\server1\project\TestFile.xlsx ==> should display while mouse hover in the textbox...

    Wednesday, February 26, 2020 8:21 AM
  • Thanks..i got it...it's working..
    Wednesday, February 26, 2020 8:36 AM