IVsTextView textView; // assume textView is initialized int startLine = 5; // 0-based line number int startColumn = 10; // 0-based column number int endLine = 7; int endColumn = 20; textView.SetSelection(startLine, startColumn, endLine, endColumn);
IVsTextView textView; // assume textView is initialized IVsUserData userData = textView as IVsUserData; // the view's user data Guid guidBackupTextViewHost = new Guid("{E052AD94-AEBE-11D0-BECC-00AFC32AC131}"); // backup host GUID object backupHost; userData.GetData(ref guidBackupTextViewHost, out backupHost); // retrieve backup host object if (backupHost != null) { IVsPersistDocData persistDocData = backupHost as IVsPersistDocData; // backup data interface persistDocData.SaveDocData(VSSAVEFLAGS.VSSAVE_Save, out string backupPath, out int cancelled); // save view's state }
IVsTextView textView; // assume textView is initialized string tooltipText = "This is a tooltip."; // the tooltip text int line = 10; // 0-based line number to show tooltip for int column = 5; // 0-based column number to show tooltip for textView.UpdateTipWindow(new IVsTipWindow[]{}, new int[]{}, new TEXTXFORMAT[]{}, tooltipText, tooltipText.Length, new Microsoft.VisualStudio.OLE.Interop.RECT[]{}, line, column, 0);This code shows a tooltip at the specified line and column position in the text view, with the text "This is a tooltip." The UpdateTipWindow method takes arrays of formatting data and window rectangles as well, but we've left them empty in this example. All of these examples make use of the IVsTextView interface, which is part of the Microsoft.VisualStudio.TextManager.Interop package.