Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"find all references" from c# designer GUI

I want to "find all references" to a control on my windows form (in designer mode). This is the painful procedure I currently use:

  1. Click on the control
  2. Goto the "Name" in the property sheet
  3. Copy the name of control in clipboard
  4. Perform a find in all files, pasting the name of control to find.
  5. Click on an arbitrary result then right-click and then "find all references"

I wonder if I miss something or there is really no way to perform such operation in simpler ways. Also I recently installed Resharper (for sake of other features).

Please tell me if there is any built-in way in VS or any methods provided by Resharper or its plugins to ease such operation,

I use VS 2010 SP1 C# and Resharper V7.0.

EDIT: It is much appreciated to mention whether your whole proposed solution or portions of it are based on VS, or Resharper when answering. (Because I installed Resharper very recently and not gone deep in its features yet), thanks a lot.

Acknowledge & Conclusion: Thanks to thersch: His answer is like a full-article and very informative for community. Thanks to wal: He pointed two delicate tips (sorted-list view, skipping name look up). Thanks to both of you: You complemented the missing parts together.

Current Status: I reported the issue to developement and have requested this as a feature to be implemented in later versions of the resharper, visit the link below for tracking the current status of the issue from the tool vendor :

https://youtrack.jetbrains.com/issue/RSRP-429747

DISCLAIMER: I have no affiliation with the tool / vendor, just a user.

like image 263
F.I.V Avatar asked Aug 21 '12 08:08

F.I.V


2 Answers

F7, (Ctrl+[)+, Shift+F12

  • F7 for viewing code
  • Ctrl+[ to navigate to a containing declaration until you reach the class name
    (Press it several times or just keep keys down until class name is reached)
  • Shift+F12 to show all references of that Control class

Again in detailed steps:

Assumed you have open the Design View of a forms control (MyControl.Designer.cs).

  1. F7
    (You don't need to select control before.)
    => Code file MyControl.cs is open.

  2. Set cursor on control's class name by:

    • selecting with mouse or
    • Ctrl+[ if you are below control's class declaration or
    • Alt+Down if cursor is above control's class declaration or
    • Alt+\ and select first class name.
      (Control's class name should be the first in all Forms controls code files.
      Alt+\ lists all members in real, non-alphabetical order (at least in my ReSharper 5.1.3))
      .
  3. Shift+F12
    => lists all usages

  4. Shift+F7
    => switches back to Design View

or

F7, select control in File Stucture window, Shift+F12

If you have already File Structure window (Ctrl+Alt+F) open (I have it always open.) switch to code view by F7, click there control's class name and press Shift+F12.

Again in steps:

Assumed you have open the Design View of a forms control.

  1. F7
    (You don't need to select control before, just have focus on Design View window.)
    => Code file MyControl.cs is open.

  2. Open File Structure window (Alt+Ctrl+F)

  3. Select control in File Structure window by:

    • selecting with mouse or
    • Ctrl+Pos1
      (Control's class name should be the first in all Forms controls code files.)
      .
  4. Shift+F12
    => lists all usages

  5. Shift+F7
    => switches back to Design View

Which shortcuts are VS and which ones are ReSharper related?

VS: F7, Shift+F7
ReSharper: Ctrl+[, Shift+F12, Alt+Down, Alt+\, Alt+Ctrl+F

like image 146
12 revs Avatar answered Oct 20 '22 16:10

12 revs


I don't think you need step 2) Goto the "Name" in the property sheet

You can just click on the property and its name will be shown in the top combo box.

Assuming you have Resharper installed and you have selected the control in the designer you can then do the following:

1) F7 (go to code)
2) Alt + \ (List members alphabetically, start typing in this dialog to filter or scroll to the one you want, you dont need to type the complete name)
3) Shift-F12 (once youve made a selection from step 2)

enter image description here

like image 23
wal Avatar answered Oct 20 '22 14:10

wal