Label text not updating, and datagridview row count shows 0

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
david62277
Posts: 9
Joined: Sun Mar 03, 2013 12:45 pm

Label text not updating, and datagridview row count shows 0

Post by david62277 »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: 5.7.173
32 or 64 bit version of product: x64
Operating system: Windows 10
32 or 64 bit OS: x64

*** Please add details and screenshots as needed below. ***
I am having problems with the latest version of Powershell studio.
1. I create a label on a form, and try to change the text of the label after clicking a button $label1.text = "whatever" - it never changes from the default text.

2. I load up a datagridview box with information and code I have used numerous times before to change the background color of every other row does not work (code below). To troubleshoot I run "write-host $datagridview1.rowcount" after loading data into the data grid view - it comes back with "0" even though there are over 200 rows.

0 .. ($datagridview1.RowCount - 1) | % {
if ($_ % 2 -eq 0)
{
$i = $_
$datagridview1.Rows[$_].DefaultCellStyle.BackColor = '#dddddd'
}
else
{
$datagridview1.Rows[$_].DefaultCellStyle.BackColor = '#ffffff'
}
}

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

User avatar
brittneyr
Site Admin
Posts: 584
Joined: Thu Jun 01, 2017 7:20 am
Answers: 5
Been upvoted: 1 time

Re: Label text not updating, and datagridview row count shows 0

Post by brittneyr »

I'm having issues replicating either of the issues you are having. Can you please upload your script(s) here:
https://www.sapien.com/support/upload
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
david62277
Posts: 9
Joined: Sun Mar 03, 2013 12:45 pm

Re: Label text not updating, and datagridview row count shows 0

Post by david62277 »

Brittney,
I uploaded a test file. I am going to try uninstalling/reinstalling.

User avatar
david62277
Posts: 9
Joined: Sun Mar 03, 2013 12:45 pm

Re: Label text not updating, and datagridview row count shows 0

Post by david62277 »

Uninstalling/Reinstalling did not change anything.

User avatar
david62277
Posts: 9
Joined: Sun Mar 03, 2013 12:45 pm

Re: Label text not updating, and datagridview row count shows 0

Post by david62277 »

Brittney,
any update?

User avatar
brittneyr
Site Admin
Posts: 584
Joined: Thu Jun 01, 2017 7:20 am
Answers: 5
Been upvoted: 1 time

Re: Label text not updating, and datagridview row count shows 0

Post by brittneyr »

From the script provided, the issues appears to be that where you are attempting to update the label text and the datagridview. Regarding the label, the text is updated, but because the generated form code comes after the your events and functions, it is being set to label1 AFTER you set it to the row count. The datagridview doesn't appear to actually populate the table until its added to the form therefore the row count would be 0. I recommend moving this code into a form or control event like $form1_Load.

If you export the script, set breakpoints at your lines, and debug that file, perhaps this may help better explain what is happening.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
david62277
Posts: 9
Joined: Sun Mar 03, 2013 12:45 pm

Re: Label text not updating, and datagridview row count shows 0

Post by david62277 »

I see, thank you! I need to look at the other forms I have created in the past, and see what I did differently.