开发者

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

 Too开发者_开发百科lTip 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.


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.


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);


call SetButtonlabels() from constructor of form1


In wich method you call SetButtonlabels()?

Try to call it after the initialization of the form.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜