Length of Textbox

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 7 years and 5 months 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
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Length of Textbox

Post by localpct »

Product, version and build: 5.2.128.0
32 or 64 bit version of product: 64
Operating system: Win 7 Pro x64
32 or 64 bit OS:
PowerShell Version: V5

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

When running a command in a text box, it cuts the character limit to this amount

3.5.30730.0 MICROSOFT CHART CONTROLS FOR MICROSOFT .NET FRAMEWORK 3.5 (K...

The command is to pull the displayversion and program name off of the computer so technicians can copy and paste it into the ticket.
If I run this in ISE or run it in PowerShell studio I get this

3.5.30730.0 MICROSOFT CHART CONTROLS FOR MICROSOFT .NET FRAMEWORK 3.5 (KB2500170)

Just wanted to bring attention to this
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Length of Textbox

Post by Alexander Riedel »

[Moved by moderator]
That is not a product problem. A standard text box does not cut text like that. You should check the properties you have set.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Length of Textbox

Post by dan.potter »

running a command in a textbox?

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

Re: Length of Textbox

Post by jvierra »

Make the textbox larger. It will only display as many characters as it has width for. The characters are all there except if you are using Format-Table to get the text. Don't use any Format commands when retrieving text. The Format commands will truncate column widths.

The "ellipses" in you string show that your retrieval method truncated the text before putting it in the textbox:

3.5.30730.0 MICROSOFT CHART CONTROLS FOR MICROSOFT .NET FRAMEWORK 3.5 (K...

You can easily overcome this by placing button on the form that copies the desired text to the clipboard.

[system.Windows.Forms.Clipboard]::SetText($textbox1.Text)
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Length of Textbox

Post by localpct »

We've already been over this - viewtopic.php?f=21&t=10580&start=20

This is why I pasted this thread in the application forum and not the scripting forum

I'm going to break this down as clear as possible... Lets start with the easy items..

My textbox is 920, 427 ( plenty big ) - my form is 950, 650
My monitors are 1920x1080
The application has been in development since March and I'm the only coder
This application is to be ran from a technicians PC while on the phone with the customer getting information from their computer for our tickets....

It populates a lot of data for us - almost 300 lines of text
FULLAPP.jpg
FULLAPP.jpg (92.47 KiB) Viewed 4244 times
When I run my code or jvierra's code in PowerShell Studio - it's exactly as I want it (zero truncating).

If I build jvierras VS running mine inside PSStudio - you can see my problem. The app on the left is the one jvierra sent over that is running as an .exe, the one on the right is running inside PSS
difference.jpg
difference.jpg (452.57 KiB) Viewed 4244 times
I'm not trying to be a tool but it's clear there is a truncating problem after the update.

Just another thing to point out to prove I'm not blowing smoke - Top script is mine, bottom is jvierras - you can tell we write code differently but it's the exact same.
code.jpg
code.jpg (139.45 KiB) Viewed 4244 times
I also have this exact same code somewhere else in the application that only displays the applications and it does the same truncating.

Now to the replies:
jvierra wrote:Make the textbox larger. It will only display as many characters as it has width for. The characters are all there except if you are using Format-Table to get the text. Don't use any Format commands when retrieving text. The Format commands will truncate column widths.

The "ellipses" in you string show that your retrieval method truncated the text before putting it in the textbox:

3.5.30730.0 MICROSOFT CHART CONTROLS FOR MICROSOFT .NET FRAMEWORK 3.5 (K...

You can easily overcome this by placing button on the form that copies the desired text to the clipboard.

[system.Windows.Forms.Clipboard]::SetText($textbox1.Text)
If I remove the | ft - autosize ..... Still truncates
As you can see I have a copy text button, pulls exactly what's in the text box 100% of the time.
dan.potter wrote:running a command in a textbox?

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

Re: Length of Textbox

Post by jvierra »

You cannot run a command in a textbox. You can add text to a textbox and you can type text into a textbox.

You are posting many pictures but there is not sign of the code you are using to copy into the textbox. Without a simple example of the code that fails we cannot begin to guess at the cause of your issue.

Simplify. Create a simple form with a textbox an the code that loads the textbox that shows the issue.

I see in one picture you are using Format-Table. This will truncate columns automatically. If you want al of the text to be displayed you need to NOT use Format commands and create a simple string output.

Post a PSF that demonstrates the issue and we will look at it.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Length of Textbox

Post by localpct »

jvierra wrote:You cannot run a command in a textbox. You can add text to a textbox and you can type text into a textbox.

You are posting many pictures but there is not sign of the code you are using to copy into the textbox. Without a simple example of the code that fails we cannot begin to guess at the cause of your issue.

Simplify. Create a simple form with a textbox an the code that loads the textbox that shows the issue.

I see in one picture you are using Format-Table. This will truncate columns automatically. If you want al of the text to be displayed you need to NOT use Format commands and create a simple string output.

Post a PSF that demonstrates the issue and we will look at it.

Seriously???

3rd picture is my code vs your code

You didn't even read my entire thread.

I'm not running a command inside of a textbox.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Length of Textbox

Post by jvierra »

I see you are using a "found function" called Get-RemoteProgram. It is this function that is causing y0ur issues. It generates broken objects because of how it is designed.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Length of Textbox

Post by localpct »

jvierra wrote:I see you are using a "found function" called Get-RemoteProgram. It is this function that is causing y0ur issues. It generates broken objects because of how it is designed.
So can someone tell me why it runs just fine in ISE or when running the application inside of PSStudio?
It's funny, our first time around you mentioned no such thing of the function creating broken objects.

We're really running out of options here until it points to PS Studio
User avatar
rmckay9969
Posts: 63
Last visit: Fri Feb 01, 2019 6:51 pm

Re: Length of Textbox

Post by rmckay9969 »

What you are experiencing looks eerily similar to a problem I had a while back. See if using the width parameter solves your problem. example below...
  1. $Var | Out-File $env:temp\Result.txt -width 400 # -Width Prevents Truncation in this instance
This topic is 7 years and 5 months 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