ReadOnly Property

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
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
nirmalks
Posts: 30
Joined: Sun Aug 02, 2015 10:01 am

ReadOnly Property

Post by nirmalks » Sat Mar 12, 2016 9:04 am

I get below error messages when using DoubleBuffered, UserPaint and other properties to reduce flickering:

ERROR: 'UserPaint' is a ReadOnly property.
Final10.psf (258, 2): ERROR: At Line: 258 char: 2
ERROR: + [System.Windows.Forms.ControlStyles]::UserPaint = $true
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : PropertyAssignmentException
ERROR:
ERROR: 'AllPaintingInWmPaint' is a ReadOnly property.
Final10.psf (259, 2): ERROR: At Line: 259 char: 2
ERROR: + [System.Windows.Forms.ControlStyles]::AllPaintingInWmPaint = ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : PropertyAssignmentException
ERROR:
ERROR: 'OptimizedDoubleBuffer' is a ReadOnly property.
Final10.psf (260, 2): ERROR: At Line: 260 char: 2
ERROR: + [System.Windows.Forms.ControlStyles]::OptimizedDoubleBuffer = ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : PropertyAssignmentException
ERROR:

How do I enable these properties?

Appreciate your help!

Thanks,
Nirmal

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

Re: ReadOnly Property

Post by jvierra » Sat Mar 12, 2016 12:44 pm

You cannot set the value of an enum.
thins like this - [System.Windows.Forms.ControlStyles]::UserPaint are static properties

Why are you trying to change these?

User avatar
nirmalks
Posts: 30
Joined: Sun Aug 02, 2015 10:01 am

Re: ReadOnly Property

Post by nirmalks » Sat Mar 12, 2016 7:41 pm

Thanks for your reply!

All I'm trying to do is avoid flickering for Winform and it's controls.

Thanks,
Nirmal

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

Re: ReadOnly Property

Post by jvierra » Sat Mar 12, 2016 8:22 pm

Set the form properties not the Enum.
What is it you are trying to set and where did you get this information from?

User avatar
nirmalks
Posts: 30
Joined: Sun Aug 02, 2015 10:01 am

Re: ReadOnly Property

Post by nirmalks » Sat Mar 12, 2016 11:02 pm

How do I set the same set of properties for a Form and its controls.

Well, my idea is to reduce the flickering. I've been reading through some posts at Stackoverflow and MSDN to reduce flickering and this is what I've got, but I'm not sure as to how I make use of them in PowerShell studio.

https://social.msdn.microsoft.com/Forum ... m=winforms

Thanks,
Nirmal

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

Re: ReadOnly Property

Post by jvierra » Sat Mar 12, 2016 11:16 pm

That article has nothing to do with what you are assigning. You need to tell us what you are trying to do or fix.

The article is about the property "DoubleBuffered". This is a stable property. The rest of what you are doing has little to do with this setting or the article you have referenced.

My best guess is this: https://msdn.microsoft.com/en-us/librar ... .110).aspx

Of course this is only useful if you are managing your own paint events. It is useless for normal operations.

If you are using complex graphics image rendering or doing high speed drawing this can reduce display issues. You can set those properties (DoubleBuffered,OptimizedDoubleBuffer) and see if it helps.

User avatar
nirmalks
Posts: 30
Joined: Sun Aug 02, 2015 10:01 am

Re: ReadOnly Property

Post by nirmalks » Sat Mar 12, 2016 11:28 pm

I can't find those properties (OptimizedDoubleBuffer and other props) on Form variable.

IntelliSense doesn't give me those properties on Form. So how do I set?

OR can you please suggest a few lines of code that I could use to reduce overall flickering for all controls on a form?

Thank you very much
Nirmal

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

Re: ReadOnly Property

Post by jvierra » Sat Mar 12, 2016 11:32 pm

In PowerShell Studio look on the form properties It is there.

User avatar
nirmalks
Posts: 30
Joined: Sun Aug 02, 2015 10:01 am

Re: ReadOnly Property

Post by nirmalks » Sat Mar 12, 2016 11:38 pm

You know what - It is there!! but I don't see when navigating properties through IntelliSense.

Thank you for all your help!
Nirmal

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

Re: ReadOnly Property

Post by jvierra » Sat Mar 12, 2016 11:44 pm

The issue with PowerShell is that it only allows for dialogs and dialogs cannot be DoubleBuffered.

Locked