DockStyle value

  • Thread starter Thread starter Bulat Baltin
  • Start date Start date
B

Bulat Baltin

Hello,

I try to use Dock property in UserControl (if it matters) in the
following way

this.Dock = DockStyle.Left | DockStyle.Bottom | DockStyle.Right;

At runtime I gets :

System.ComponentModel.InvalidEnumArgumentException: The value of
argument 'value' (7) is invalid for Enum type 'DockStyle'.

How to fix it?

Regards,
Bulat Baltin
 
Hi,

because method this.Dock contains something like this:

if (!((value >= 0) && (value <= 5)))
{
throw new InvalidEnumArgumentException("value", (int) value,
typeof(DockStyle));
}

but DockStyle { None =0, Top, Bottom, Left = 3, Right = 4, Fill = 5 } with
combination DockStyle.Left | DockStyle.Right give you 7.

Regards,
Alex
http://devkids.blogspot.com
 
Hello Alex,
Thanks. I just discovered that in my case

this.Dock = DockStyle.Bottom;

is enough and actually does what I wanted - docking to left and right
borders as well. The misleading fact for me was that in other place
for docking to left border I used

this.Dock = DockStyle.Top | DockStyle.Bottom | DockStyle.Left;

and it worked well. Now I see that DockStyle.Left is enough.

Regards,
Bulat Baltin.
 
You can only dock to one edge at a time...this means that the Dockstyle
values should not be or'ed

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
 
Back
Top