PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How to get message over the text box

 July 12, 2022     c#, messages, textbox, winforms     No comments   

Issue

I have interface with textbox which has list of commands, and I want to show this list when the user hover the mouse on textbox.

I can put message with label, but seems it is not the best way, looks not really good

Here is how I want get it and and same with labels:

enter image description here

Maybe you can advice me some better way to show it, also very interesting


Solution

As Reza Aghaei had already said to use a ToolTip. Here's how you can do it:

Creating and returning the list:

static List<string> PopulateList()
{
    List<string> mylist = new List<string>();
    mylist.Add("insert (a1) to get this");
    mylist.Add("insert (a2) to get this");
    mylist.Add("insert (a3) to get this");
    mylist.Add("insert (a4) to get this");
    ...
    ...
    return mylist;
}

Displaying the Tooltip on the Enter event of the TextBox:

private void textBox1_Enter(object sender, EventArgs e)
{
    string tooltiptext = "";
    List<string> mylist = PopulateList();
    foreach (string listitem in mylist)
    {
        tooltiptext += listitem + "\n";
    }
    ToolTip tt = new ToolTip();
    tt.Show(tooltiptext, textBox1, 2000);
}

Result:

tooltip



Answered By - Raktim Biswas
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing