Visual Studio 2010 extension gets selected text

I am writing my own extension. I created a toolbar button. The template I used was “Visual Studio Package”, and during the wizard it was possible to create a command button (or something like that)

So, the button appears, but I can’t figure out how to get the current document or the selected text in the document.

Any help would be appreciated.

+3
source share
1 answer

There are two ways to approach it:

  • DTE, (DTE.ActiveDocument) (((TextDocument)activeDoc).Selection.Text), DTE , : DTE dte = GetService(typeof(SDTE)) as DTE; , null.
  • , . Align Assignments, (). .
+7

Source: https://habr.com/ru/post/1752757/


All Articles