Button not working after move to other tab(?)

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Button not working after move to other tab(?)

Post by stevens »

Hi,

I my gui, I have moved a button to a different tab page, since then it is not responding when publishing my project (= making an exe of it and running it).
The button works fine when I launch the project in PS Studio, not anymore when in the exe.
Tried to recreate the button but didn't help. Checked the code and it is correct. The code behind the button make the button disable when code executes and re-enable it afterwards but that does not happen also.

Any idea what might cause this? Hope this would be a known issue which has a woraround.

Thanks.
S.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Button not working after move to other tab(?)

Post by jvierra »

It is most likely that the button is not hooked to the event. It is also possible that your project is somehow corrupted. Remove all build and temp files from the project and rebuild.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Button not working after move to other tab(?)

Post by stevens »

Thanks, but if the button would not be linked to the code, it would not work in the project when I launch it in PS Studio either, right?
Note: how do I remove all "temporary files" from a project?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Button not working after move to other tab(?)

Post by jvierra »

Recreate the project by copying all project forms to a new project.

There is no reason why this wouldn't work in an EXE assuming the files are not damaged in some way.

Start by creating a new project with a minimal example of the failure. Chances are you cannot reproduce the issue in a new project. If you can post the new simple project as an example.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Button not working after move to other tab(?)

Post by stevens »

Thanks. I copied my project and removed the temporary files which solved the issue.
One more thing: a specific ps1 is dissapearing all the time from my project.
Just try to understand: when I refer to a ps1 in my project, f.e. Import-Module "$ScriptsFolder\mymodule.ps1", do I need to add the folder in the project (add folder, then add existing files) or is it sufficient the folder is there to have them available in the exe?

Just wonder when I need to add the files in the project, I guess only when editing is needed in the GUI. Hope my question is clear(?)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Button not working after move to other tab(?)

Post by jvierra »

The module has to be distributed with your project or must exist on the target system. WHat I see is that you are trying to load a script (PS1) file as a module. That does not make it a full module. (PSM1)
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Button not working after move to other tab(?)

Post by stevens »

Thanks for that.I'll change it into a psm1.
I mentioned that I copied the script to a new one and everything was solved. I meant that I deleted some tempfiles, but not all issues are solved apparently. Some buttons still don't work.

So I'd like to start a new project and copy all items over. However, I don't understand how I should do this. Start new project folder outside PS Studio, then copy only the project files over, start PS Studio, import them one by one (didn't see an option to import more then one file at once)?
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked