Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Winforms ViewCode does not open code 22 Aug 2022 19:03 #23443

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1608
  • We have Winforms form, see MyWindow.prg with a toolbar with some buttons. I see that there's a right mouse menu option View code in the MyWindow.prg [Design].

    The code behind of the buttons resides in a separate program MyWindowCode.prg. When I try View code the code file MyWindow.prg is opened and the cursor is placed on top. But that's not where my code is.

    Now I have to open a Properties tab first, copy the name from (Design) and paste it in a solution wide Search box.

    Is there something I can do to do that less time consuming?

    Dick

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 22 Aug 2022 20:36 #23444

    • Fabrice
    • Fabrice's Avatar


  • Posts: 349
  • Hi Dick,
    I think that "View Code" is not specific to the element you are on, it just open the file that contains the User-Code of the Form.
    To jump to the code that replies to an event, either you doubleclick on the control, and it will open/create the method that replies to the default event, or you can go to the Properties panel, select the lightning icon (Event) then doubleclick on the corresponding event...it should jump to the code.

    HTH,
    Fab

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 22 Aug 2022 21:57 #23445

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1608
  • Hello Fabrice,

    Unfortunately neither of these methods work. For some reason 1 of the (currently 4) toolbar button click methods resides in MyWindow.prg. The doubleclick (button or event) always opens that specific event while 3 of the events, residing in the separate MyWindowCode.prg never open (even though the name shows correctly in Click.)

    It looks to me that if the code isn't in the windows with the same name as the Designer, X# is unable to find the code.

    Dick

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 22 Aug 2022 23:32 #23447

    • robert
    • robert's Avatar


  • Posts: 3446
  • Dick,

    The normal behavior (also for C#) is that the contents of the Form.prg and Form.designer.prg are merged into one logical codemodel and fed to the Window Editor. Each "CodeObject" in this CodeModel is marked with a property that indicates where it came from, so when saving the fields and methods are written back to the same file.

    If you have code in another file then this is not included in this Codemodel and therefore the double click does not select it.
    AFAIK this is also true for C#.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 23 Aug 2022 12:10 #23450

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1608
  • Hello Robert,

    If you have code in another file then this is not included in this Codemodel and therefore the double click does not select it.
    AFAIK this is also true for C#.

    You are right; I tried it in C# and I see it doesn't work there either.

    I'll add it to my growing list of things-that-get-worse-in-VS-compared-to-VO.

    Dick

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 23 Aug 2022 12:32 #23452

    • robert
    • robert's Avatar


  • Posts: 3446
  • Dick,
    I can probably make it work. Can you create a GitHub ticket for this so I will not forget to look at this.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 24 Aug 2022 00:03 #23462

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1608
  • Hello Robert,

    I can probably make it work. Can you create a GitHub ticket for this so I will not forget to look at this.

    It would be quite something that you would (again) fix something which Microsoft is unable to, or just don't care.

    Kees informed me that he moved the code to a different program because of an earlier X# bug where he lost code in the code behind. This bug was fixed so personally I think I keep the program, but move the click event to the code behind program, calling the actual code in the separate program. So it would certainly be good if you can indeed fix it but I would give it low priority.

    I have created a throw away Github account szh48002 to post a a GitHub ticket, #1103.

    Dick

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 24 Aug 2022 09:08 #23466

    • robert
    • robert's Avatar


  • Posts: 3446
  • Dick,

    Hello Robert,
    I have created a throw away Github account szh48002 to post a a GitHub ticket, #1103.
    There is no ticket 1103 (anymore). If you have deleted your account then it has been deleted with it.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 24 Aug 2022 11:01 #23471

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1608
  • Hello Robert,

    I didn't delete it. But it's Microsoft, so it is to be expected that it doesn't work.

    Dick

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 24 Aug 2022 11:17 #23472

    • robert
    • robert's Avatar


  • Posts: 3446
  • Dick,

    I would not define that as "it does not work". Maybe it does not work as you would expect it.
    If you delete an account, what should happen with the issues reported by that account?
    Apparently, someone decided that since nobody else interacted with the issue, this issue was yours and yours only, so it should be deleted.
    I think that makes perfect sense: "the right to be forgotten".

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Winforms ViewCode does not open code 24 Aug 2022 12:28 #23477

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1608
  • Hello Robert,

    I would not define that as "it does not work". Maybe it does not work as you would expect it.
    If you delete an account, what should happen with the issues reported by that account?

    As I wrote clearly: I did not delete the account. I only used a temporary e-mail address where I confirmed the creation of the account, which is, after all, a prerequisite to post an issue anyway. I posted it, it got a number, I saw it published and the next day you write it isn't there anymore.

    I expect either they don't accept my account or, when they accept and let me publish, that it remains there.

    That's why I avoided Github in the first place like I do with most Microsoft products. And it proves I do that for a good reason.

    Dick

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1