Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Calling SelectText (and other InfoPath methods with optional parameters) in C# or VB.NET

Calling SelectText (and other InfoPath methods with optional parameters) in C# or VB.NET

  • Comments 2

In the introduction to SP1, InfoPath added C# support. One issue that some people may run into is that certain OM calls have optional parameters. One such method is the SelectText() method in the View object. The context ID is optional and it not always easily found. In JavaScript of VBscript, the optional parameter would just be omitted and everything would work. In managed code (C# and VB.NET), you cannot omit optional parameters. To get around this, managed code has System.Reflection.Missing.Value which can be used in place of the optional parameter. This will achieve the same result as omitting optional parameters.

Leave a Comment
  • Please add 6 and 8 and type the answer here:
  • Post
  • This doesn't work with VSTO 4, the SelectText() method now takes the node and a string.  The string is the context ID but since its no longer an object, you can't use Type.Missing.

  • See the MSDN article, msdn.microsoft.com/.../bb251012(v=office.12).aspx for how to get the context ID.  With the ID, the SelectText method works from C# in VSTO 4.

Page 1 of 1 (2 items)