Winforms ViewCode does not open code

This forum is meant for questions and discussions about the X# language and tools
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms ViewCode does not open code

Post by ic2 »

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
User avatar
Fabrice
Posts: 459
Joined: Thu Oct 08, 2015 7:47 am
Location: France

Winforms ViewCode does not open code

Post by Fabrice »

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
XSharp Development Team
fabrice(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms ViewCode does not open code

Post by ic2 »

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
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Winforms ViewCode does not open code

Post by robert »

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
robert@xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms ViewCode does not open code

Post by ic2 »

Hello Robert,
robert post=23447 userid=253 wrote: 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
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Winforms ViewCode does not open code

Post by robert »

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
robert@xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms ViewCode does not open code

Post by ic2 »

Hello Robert,
robert post=23452 userid=253 wrote: 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
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Winforms ViewCode does not open code

Post by robert »

Dick,
ic2 post=23462 userid=455 wrote: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
robert@xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms ViewCode does not open code

Post by ic2 »

Hello Robert,

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

Dick
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Winforms ViewCode does not open code

Post by robert »

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
robert@xsharp.eu
Post Reply