Find another part of PartialClass in Visual Studio IDE?
Suppose I have a partial class
in my application.
Let's say I have one part of this class open in Visual Studio and I want to find the other parts. How can I do this? Is there a keyboard shortcut or any other method that I can use to quickly navigate to the other parts of my class?
This would be useful because in a large application, there are so many individual *.cs files that manually searching for partial classes gets very inefficient.
Solution 1:
If you open the context menu on the class name and click "Go To Definition (F12)", then the panel "Find Symbol Results" will show at the bottom (by default) of Visual Studio. Here you'll find all (partial) definitions of that class.
Solution 2:
In my case (Visual Studio 2013 and also Visual Studio 2015) the solution CodeCaster describes did not work for me - Find Symbol Results doesn't show up as described in the answer.
But I found 2 other ways to solve it, which work for me. Do the following:
Solution 1
Tested with Visual Studio 2013/2015, Visual Studio 2017 and Visual Studio 2019
- Right-click and select "Go to definition". This will open up one of the (possibly many, but in most cases two) parts of the class.
- Put the cursor on the class name to mark it, i.e.
public partial class
MyClass
Press F12. A "declarations" window will open. Click into it to give it the focus.
Press F8 to navigate to the next, or SHIFT+F8 to navigate to the previous declaration (or click on the previous/next buttons with the mouse).
Note: Only if there is more than 1 partial class, you will see the file names where the parts of the class are found:
Solution 2
Tested with Visual Studio 2017
- Put the cursor on the class name to mark it, i.e.
public partial class
MyClass
- Press ALT+SHIFT+F12. This will search the symbol selected in the entire solution.
- All occurances of the class are listed in the Find Symbol Results window.
The disadvantage of Solution 2 is that the references are listed as well, not only the partial classes.
Updated Answer for newer versions of Visual Studio (2019).