$textbox.text value no longer accessible

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 5 years and 2 days 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
cs_engineering
Posts: 10
Last visit: Mon Oct 31, 2022 7:12 am

$textbox.text value no longer accessible

Post by cs_engineering »

Hi, in my attempt to convert controls split between the form and a panel into tabpages, I have run in to a strange problem. The textbox that resided on a panel, was cut and pated into a tabpage of tabcontrol. Now I can not figure out a way to access the text property of that text box, $textbox.text. It there adifferent way to access this property now that the text box is a child of a tabpage instead of a panel?

Thank you
User avatar
brittneyr
Site Admin
Posts: 1654
Last visit: Thu Mar 28, 2024 6:54 am
Answers: 39
Been upvoted: 30 times

Re: $textbox.text value no longer accessible

Post by brittneyr »

[TOPIC MOVED TO POWERSHELL GUI BY MODERATOR]
Brittney
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $textbox.text value no longer accessible

Post by jvierra »

What is the name of the textbox in the properties tab?
User avatar
cs_engineering
Posts: 10
Last visit: Mon Oct 31, 2022 7:12 am

Re: $textbox.text value no longer accessible

Post by cs_engineering »

$textboxLogonName

It was working correctly and it's contents were accessible when it was a child of a panel control. Once I did cut (from panel) and Paste (into $tabpage1 of $tabcontrol) I can no longer get to the contents.

It actually turns out that the entire set of controls, two textbox controls used for input and a a button used to execute a procedure when clicked, no longer work once they were pasted into the $tabpage
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $textbox.text value no longer accessible

Post by jvierra »

What is the name of the control as displayed on the properties page on the panel in the designer. YO are giving me the name of a variable. I need the name you see in the designer on the control properties page. Look at the "Name" property in the list.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $textbox.text value no longer accessible

Post by jvierra »

Here is a picture of what to look for:
tbname.png
tbname.png (12.06 KiB) Viewed 2582 times
User avatar
cs_engineering
Posts: 10
Last visit: Mon Oct 31, 2022 7:12 am

Re: $textbox.text value no longer accessible

Post by cs_engineering »

#### Solved ##########

Turns out when you cut and past a control, say a $button from any parent location and make it a child of a new parent, the default action / event may get dropped. In my case, every button had it's onClick Action set to $NULL / blank and needs to be pointed back to the correct function.
1.PNG
1.PNG (6.04 KiB) Viewed 2571 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $textbox.text value no longer accessible

Post by jvierra »

AS for you question in support.

When creating a tab control it is necessary to carefully select the tab page then be sure you have the tab page container selected before dropping in or copying a control.

The more complex controls are really control containers and have multiple parts. dropping incorrectly can cause odd things to happen. Once you master cutting and pasting with controls or when moving a control from one place to another then this is easy.

When copying a control at any time the events are NEVER copied. Only cut/paste or drag/move/drop keeps the events. This is actually true of all things in Windows.

The events have nothing to do with assigning text or reading the controls text property.

Designing and coding with Windows forms for anyone with no forms or designer experience is a bit of a challenge because many things are counter-intuitive. The designer also follows all Windows standards which is not true of many GUI programs. The Sapien designer is based on Visual Studio and follows all standards for a VS type designer. It is a tool that is designed to make programming a GUI easier and is not like many GUI programs. Once you get used to the techniques it becomes very easy to use. The tab control always gets every new user because its behavior has to be complex. C# code will not work well when using the designer but can be used as a template for how to alter the control with script once you learn the properties that can break the control in the designer.
This topic is 5 years and 2 days 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