2014年7月13日 星期日

[RESOLVED] From Visual Studio in “design view”, is possible to have the correspondig lines of code highlighted in “source view”?


I use VS2010 with GridView, FormView ecc...


I frequently switch from Design View (in which for example I am visually editing something inside a FormView EditItemTemplate), to Source View.


Note that this happen when I am editing something inside a EditItemTemplate


So, for example if in Design View I have a TextBox selected, when I switch to Source View I'd like to have ONLY the corresponding lines selected, instead VS2010 highligh ALL the FormView EditItemtemplate code, from start to finish (which can be 1000 lines
long!).


Is possible or not to instruct VS to select only the relevant lines?




No it is not posible.



Because gridview is one control and you are placing another controls inside it. So it is consider as part fo grid view so it will select whole grid view. And also you can not directly access that control in code behind just because of same reason.




Wait!


Now it is functioning correctly!


From Design view:



  1. I select an TextBox --> ... is selected in source view
  2. I click in a cell -->
  3. I highligh a full table row in design --> the code inside ... is selected in source, wonderful!


From source view:



  1. I click wherever in a line inside the whole table is highlighted in design view
  2. I click inside a the control is highlighted in design view

  3. WONDERFUL!!! Surprised


    So, what the hell has got messed before, and what I have done in the meantime that reset things?


    (In the meantime I have close and reopend VS (not working), rebuild solution, refactored code, reformatted code, changed formatting tag options, ecc...)



    Arrghhh!!!


    I edited the code from the Source view, removing a

    line, the VS asked me to refresh the view, claiming that Design view is out of sync with Source view.


    I clicked to synchronize view, and now it's not functioning anymore!!! Yell


    I thought it could be because some background VS task didn't have yet enough time to complete, so I waited ... but after something like 10 minutes of wait it's not working yet....


    So, I clicked undo to insert the

    lines back... and (not so surprisingly) the highlight works again!!!


    What is happening???



    PS: Important info. If instead I remove the

    line from the Design view, via mouse dx popup menu-->Delete rows-->Delete row the Source/Design remains in synch and the highlight functionality continue working Undecided



    Up to now I have found this workaround... that seems to be working :-)


    You have manually edited the source code, so messing up the synchronize with design view...!



    1. Select a control in Design view
    2. Change something in the Properties window, (for example set width=100px, or toggle the Enabled property)
    3. WAIT.... (your change forces VS to update the source code!)
    4. After some time (something like 5-10 seconds for my slow machine ;-)), VS updates the code, adding/changing the relevant code 
    5. And now the bidirectional highlight functionality works again!
    6. Remember to Change back/Toggle the modified property Tongue Out 

    沒有留言:

    張貼留言