Dinesh
Dinesh

Reputation: 2066

Problem with ToolTip in Windows Form(C#)

I have form with 4 buttons and Image. For all these controls i have added tool tip by using the following code

 ToolTip objToolTip=null;
    .....
    public Form1()
    {
        objToolTip=new ToolTip();
    }
    .....
    //Used to set the button lables based on Data from database
    private void SetButtonlabels()
    {
        objToolTip.SetToolTip(btnSAPConnect, "Connects to SAP");
    }

the problem is, Once the form is opened, the tool tips are not coming immediately even if we move our mouse over the control. But Once i click on the form, then tool tips are working properly. I am not sure which is causing the problem.

Can anybody please help to fix this issue.

Upvotes: 0

Views: 2687

Answers (5)

Jemaine
Jemaine

Reputation: 21

I hope this helps. It solved the problem i had of the tooltip not showing on the form_load event. I noticed the tooltip working after i manually clicked on my WindowsForm control.

For some reason it won't work until your WindowsForm control is active (Usually once a user clicks on the Form).

So to solve this you will need to activate your Form behind code.

this.Activate();

ToolTip toolTip = new ToolTip();
toolTip.ToolTipTitle = "Info";
toolTip.ToolTipIcon = ToolTipIcon.Info;
toolTip.UseFading = true;
toolTip.UseAnimation = true;
toolTip.IsBalloon = true;
toolTip.ShowAlways = true;
toolTip.AutoPopDelay = 5000;
toolTip.InitialDelay = 1000;
toolTip.ReshowDelay = 500;
toolTip.Show("This is button1", button1, 10000);

Upvotes: 2

Dinesh
Dinesh

Reputation: 2066

I have just set focus on one control on the form. It started working.

Upvotes: 0

Dan Puzey
Dan Puzey

Reputation: 34198

You said this:

Once the form is opened, the tool tips are not coming immediately even if we move our mouse over the control. But Once i click on the form, then tool tips are working properly.

This leads me to think it's standard windows behaviour, and that your form just isn't getting focus when you open it. Tooltips in many apps will only work if their parent window is activated.

Upvotes: 2

Khaniya
Khaniya

Reputation: 63

call SetButtonlabels() from constructor of form1

Upvotes: 1

alfdev
alfdev

Reputation: 1049

In wich method you call SetButtonlabels()?

Try to call it after the initialization of the form.

Upvotes: 0

Related Questions