none
Is there a way to set focus to a custom task pane? RRS feed

Answers

  • Hi Elischein,

    Can you descripte more detail about the secnario you are handling? As far as I know, we can set the focus to the controls on the custom taskpane. And here is a sample to set the focus from the button on the ribbon:

      private void btnActiveCustomTaskPane_Click(object sender, RibbonControlEventArgs e)
            {
                         Globals.ThisAddIn.CustomTaskPanes[0].Control.Controls[0].Focus();
            }

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 14, 2014 6:34 AM
    Moderator

All replies

  • Did you try to use the Focus method of the UserControl class (a parent of your task pane form)?
    Sunday, July 13, 2014 2:53 PM
  • I tried, it is not working
    Sunday, July 13, 2014 3:02 PM
  • Hi Elischein,

    Can you descripte more detail about the secnario you are handling? As far as I know, we can set the focus to the controls on the custom taskpane. And here is a sample to set the focus from the button on the ribbon:

      private void btnActiveCustomTaskPane_Click(object sender, RibbonControlEventArgs e)
            {
                         Globals.ThisAddIn.CustomTaskPanes[0].Control.Controls[0].Focus();
            }

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 14, 2014 6:34 AM
    Moderator
  • Hi elischem

    I assume you mean take the focus from the selection in the document to the CTP window?

    There's nothing in the Word APIs that will do that. There is the keyboard combination Shift+F6 that cycles between the different parts of the command UI (Ribbon, task panes). Theoretically, you could send that command, using SendKeys, but there's no direct way to detect in which command interface the focus is. It might be possible using the Windows API, but I don't know how to do it...


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, July 14, 2014 2:02 PM
    Moderator
  • The problem was that when I tried to give focus the control, he still was not ready. I solved it by using System.Windows.Forms.Application.DoEvents() before giving the focus . Did you have a better way?

    private void button1_Click(object sender, RibbonControlEventArgs e)
            {
                Microsoft.Office.Tools.CustomTaskPane searchPane = ThisAddIn.getSearchPane(ThisAddIn.app.ActiveWindow);
                searchPane.Visible = true;
                System.Windows.Forms.Application.DoEvents();
                searchPane.Control.Controls["textBox1"].Focus();
            }


    Tuesday, July 15, 2014 5:57 AM
  • Hi Elischein,

    What do you mean he still was not ready? Can you explain more detail? Since you are using  System.Windows.Forms.Application.DoEvents(), it seems realte to the design of task pane. Do you put the task which costs much time in some event? If yes, I suggest you considering developing with multithreading.

    You can refer to link below about multithreading developing.

    Safe, Simple Multithreading in Windows Forms, Part 1

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 17, 2014 1:56 AM
    Moderator