Index

 < Free Open Study > 



Display a Variable or Method Declaration Line in a Code Window

If you have a window name and a line number, you can display the desired line in the window by calling the DisplayCodeSelection method shown in the following code. You can get window names and line numbers of all CodeElement members by using the CodeModel object as shown previously. You will notice that this code method will automatically open the desired window for you and then select the specified line. The window name parameter (rsWinName) is a concatenation of the solution name, the project name, and the file name separated by backward slashes.

    Public Sub DisplayCodeSelection(ByVal rsWinName As String, _     ByVal riLine As Integer)     ' Open the specified window, move to specified line,     ' and select the line.     ' This method can be called by features such as search     ' program, project browser, and track changes.     ' rsWinName="SlnName\PrjName\modulename.vb"     Dim s As String     Try       's = Mid(rsWinName, InStrRev(rsWinName, "\") + 1)       oVB.Windows.Item(Constants.           vsWindowKindSolutionExplorer).Activate()       oVB.ActiveWindow.Object.GetItem           (rsWinName).Select(vsUISelectionType.           vsUISelectionTypeSelect)       'oVB.ActiveWindow.Object.DoDefaultAction()       oVB.ExecuteCommand("View.ViewCode")       System.Windows.Forms.Application.DoEvents()       Dim objTextDoc As TextSelection = _          oVB.ActiveDocument.Selection       objTextDoc.StartOfDocument()       objTextDoc.MoveToLineAndOffset(riLine, 1, False)       objTextDoc.MoveToLineAndOffset(riLine + 1, 1, True)       oVB.ActiveDocument.Activate()     Catch ex As System.Exception       MsgBox("DisplayCodeSelection: " & ex.Message)     End Try    End Sub



 < Free Open Study > 



Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net