Home > Software design >  Tab stops in windows form in Office VSTO addin don't work
Tab stops in windows form in Office VSTO addin don't work

Time:11-18

I'm writing a simple VSTO add-in for Office. When the user clicks a button a single form appears, and on the form there are some single-line textboxes, some buttons and some labels. This is all in VB.NET.

Everything works as expected - except I cannot tab between controls on the form. I have set the TabIndex and TabStop properties (actually, left them at defaults, which look OK). I've also tried programmatically setting TabIndex and TabStop in the form's Shown handler - but this made no difference. Changing runtime from .NET 4.5 to 4.6 makes no difference.

The odd thing is that if I use exactly the same form (copy & paste the .vb file) in a Windows Forms App, the tab stops work. It seems there's something about this VSTO project (or perhaps all VSTO projects) that is stopping tabbing working.

I am using Visual Studio 2017 and the host application for the VSTO addin is MS Project 2016.

CodePudding user response:

The difference between a standalone WinForms application and your Office add-in is the host application (can be MDI or SDI application).

Most probably you need to specify the parent window handle to the Show method. The method accepts an instance of the IWin32Window interface which represents the top-level window that will own this form.

  • Related