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.
This topic is 4 years and 1 week 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.
User avatar
IFG_Infra
Posts: 9
Last visit: Fri Dec 22, 2023 12:36 pm

Label text not updating, and datagridview row count shows 0

Post by IFG_Infra »

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: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

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
SAPIEN Technologies, Inc.
User avatar
IFG_Infra
Posts: 9
Last visit: Fri Dec 22, 2023 12:36 pm

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

Post by IFG_Infra »

Brittney,
I uploaded a test file. I am going to try uninstalling/reinstalling.
User avatar
IFG_Infra
Posts: 9
Last visit: Fri Dec 22, 2023 12:36 pm

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

Post by IFG_Infra »

Uninstalling/Reinstalling did not change anything.
User avatar
IFG_Infra
Posts: 9
Last visit: Fri Dec 22, 2023 12:36 pm

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

Post by IFG_Infra »

Brittney,
any update?
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

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
SAPIEN Technologies, Inc.
User avatar
IFG_Infra
Posts: 9
Last visit: Fri Dec 22, 2023 12:36 pm

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

Post by IFG_Infra »

I see, thank you! I need to look at the other forms I have created in the past, and see what I did differently.
This topic is 4 years and 1 week 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.