Solution4.FindProjectItem(String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在项目中定位项。
public:
EnvDTE::ProjectItem ^ FindProjectItem(System::String ^ FileName);
public:
EnvDTE::ProjectItem ^ FindProjectItem(Platform::String ^ FileName);
EnvDTE::ProjectItem FindProjectItem(std::wstring const & FileName);
[System.Runtime.InteropServices.DispId(42)]
public EnvDTE.ProjectItem FindProjectItem (string FileName);
[<System.Runtime.InteropServices.DispId(42)>]
abstract member FindProjectItem : string -> EnvDTE.ProjectItem
Public Function FindProjectItem (FileName As String) As ProjectItem
参数
- FileName
- String
必需。 要定位的项目项的名称。
返回
ProjectItem 对象。
实现
- 属性
示例
Sub SolnFindProjectItemExample(ByVal dte As DTE2)
' fIND a project item in a solution.
' Make sure you have a solution open in Visual Studio before running this example.
Try
Dim soln As Solution4 = _
CType(_applicationObject.Solution, Solution4)
MsgBox("Finding a project item in the solution ")
' Find the specified project.
Dim proj As ProjectItem
proj = soln.FindProjectItem _(soln.Projects.Item(1).ProjectItems.Item(1).Name.ToString())
MsgBox(proj.Name.ToString())
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
using System.Windows.Forms;
public void CreateExample(DTE2 dte)
{
// Find a project item in a solution.
// Open a solution in Visual Studio before running
// this example.
try
{
Solution4 soln = (Solution4)_applicationObject.Solution;
MessageBox.Show("Finding a project item in the solution.");
ProjectItem proj;
proj =
soln.FindProjectItem
(soln.Projects.Item(1).ProjectItems.Item(1).Name.ToString());
MessageBox.Show("The project item found is: "
+ proj.Name.ToString());
}
catch (SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
注解
FindProjectItemOpenFile对给定的文件名执行-类型搜索。 找到的第一个项目,该项目为名称返回其 ProjectItem 对象。 如果在解决方案中找不到该文件, null 则返回。