form region having only DocSiteControl is not showing any carat position when opening. RRS feed

  • Question

  • Hi All,

    I am using vsto 4 with VS2010 and developing the addin for office2010 outlook.

    I am having a form region which i had created by outlook as .ofs file and which is having only one control which is DocSiteControl which actually shows the body of the mail. When opening this form region run time, since it is having only one control it should have the focus automatically to DocSiteControl but its not having the focus. I also try by pushing the tab button but focus is not coming there. Only after clicking by mouse it is showing the carat in DocSiteControl. I also try to find any SetFocus method by which i can set the focus to DocSiteControl in FormRegionShowing event but dont find any such method for this control.

    Does i am missing something here or there any method to set the focus to DocSiteControl in form region.

    Thursday, March 17, 2011 11:58 AM

All replies

  • In the form initialization code you should be able to get all the controls on the form region design surface and iterate them to find your body control or to explicitly set a control object to your control. You can then use the control.SetFocus method.

    As the body control isn't being backed by any of the OLK* controls you might have to do that by getting an Inspector for the form region object and using the ModifiedFormPages collection to get the Controls collection as an MS Forms 2.0 set of controls to iterate.

    I haven't tried this as it's not usually recommended to reuse the DocSiteControl as there can only be one of those in an item, but see if it helps. I have used similar methods where I used either OLK* or Windows Forms controls on the form region design surface.


    Ken Slovak MVP - Outlook
    Thursday, March 17, 2011 1:33 PM
  • Thanks Ken for your reply.

    I tried the below code in FormRegionShowing method where message is the DocSiteControl and in debug i found the obj is not null.

    var obj = message as ControlClass;
    But even after calling the SetFocus method it is not setting the focus to body control. It is setting only after clicking by mouse.
    Friday, March 18, 2011 6:15 AM