Datagridview - Tabpage freezing on TabControl

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.
User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

Datagridview - Tabpage freezing on TabControl

Post by angelofstealth »

Using Jobtracker to pull data from remote computers
- Working fine, not freezing GUI
- Once all results are back i populate datagridviews

If i click on a tab for the first time that has a datagridview with lots of data it freezes the form, after a few seconds restores and the tab revealed with the data. I have tried refreshing the tabs/tabcontrol after i populated the datagridviews but it still freezes on tabs with datagridviews with lots of data. Is there a way around that, or is that the limitation of the gui/datagridview on a tabcontrol/tabpage? Thanks,

jvierra
Posts: 14553
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview - Tabpage freezing on TabControl

Post by jvierra »

It all depends on how you are loading the grid.

User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

Re: Datagridview - Tabpage freezing on TabControl

Post by angelofstealth »

Example:
$ComputerWinUpdates = $global:AllWindowsUpdates | Select-Object 'Computer Name', 'Description', 'Fix Comments', 'Hot Fix ID', 'Installed By', 'Installed On', `
'Installed Date', 'KB Article', 'Name', 'Service Pack In Effect', 'Status', 'Index' | Sort 'Computer Name', 'Index'
Update-DataGridView $datagridviewWinUp $ComputerWinUpdates

jvierra
Posts: 14553
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview - Tabpage freezing on TabControl

Post by jvierra »

That doesn't tell us anything. Where are you executing this code?

User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

Re: Datagridview - Tabpage freezing on TabControl

Post by angelofstealth »

This is my routine...

1) Computer Objects read through a loop, within the loop Add-Jobtracker is kicked off (job-named after Computer Object)
2) Within the $CompletedScript, results are returned from the $jobscript and passed into global array variables
3) A global counter is increased every time within $CompletedScript. Once the global counter match the global counter of total Computer Objects from step 1, datagridviews are updated. As I only want to update the datagridviews once all the trackers data is returned.

I do refresh the form and tabcontrol at the end of the $CompletedScript. Do I need to refresh each tabpage and datagridview after the load?

jvierra
Posts: 14553
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview - Tabpage freezing on TabControl

Post by jvierra »

That does not tell us how the tab is being loaded. Without a code example it is not really possible to know where you are failing. I recommend using the debugger to step through the tab activation.

Once the grid is loaded it would not take time to display the tab.

User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

Re: Datagridview - Tabpage freezing on TabControl

Post by angelofstealth »

I can't use the debugger, as I am testing in a different domain/environment from where i have the sapien software installed.

Attaching psf
Attachments
MainForm.psf
(211.25 KiB) Downloaded 63 times

jvierra
Posts: 14553
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Datagridview - Tabpage freezing on TabControl

Post by jvierra »

Best I can tell you is that you are reloading everything every time you change your tabs.

I cannot spend the time trying to decode 2000+ lines of code. It also seems that you have way too much code for what you are trying to do. You should only have about 300 lines if you use events and jobs correctly.

User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

Re: Datagridview - Tabpage freezing on TabControl

Post by angelofstealth »

In regards to the issue i am asking about is in the control $buttonGUIQuery_Click={} , there is no duplication of code being used. The Scriptblock in the $jobscript is coded for when data can be or not be pulled back by a remote session and that the tables/columns match.

I don't see where you pointing out where i reloading everything when changing tabs, when i have no click event triggers for the tabcontrol. The tabcontrol datagridviews are wipe and populated anytime the $buttonGUIQuery_Click={} is ran. There is 2000 lines of code due to different procedures being completed, this is one task being completed plus logging.


$buttonADExecute - Is what goes out to Active Directory or whatever the user selected from the dropdown and pulls in the objects into the datagridview1 on Active Directory Computer Objects
$buttonGUIQuery - Takes what the user selected from the Active Directory Computer objects datagridview and passes the computer name to each tracker to pass a scriptblock to pull local data.

User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

Re: Datagridview - Tabpage freezing on TabControl

Post by angelofstealth »

I did find this old article that seems to be what i am going through with a datagridview having many rows/tables. I only have this freezing on the tabs with lots of data/tables, ie Windows Updates will have lots of data vs the CPU tab.

viewtopic.php?t=6470

Locked