Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to set controls anchor property

Tags:

One of my windows constitutes many controls, I need to set anchor property top and right ,Note: I need to handle positional property independently for each control. I don't want to set this property manually .Need help to set anchor property for the control dynamically.

I write the bellow syntax

 DynamicControlsProperty od = new DynamicControlsProperty();     foreach (Control item in this.controls)     {         item.Anchor = AnchorStyles.None;         item.Anchor = (AnchorStyles.Top | AnchorStyles.Right);     } 

Using the above syntax on my window form, controls are not appear as anchor set on the above syntax.Controls are appear as default anchor set.

like image 229
shamim Avatar asked Mar 02 '11 09:03

shamim


People also ask

What does the Anchor property control?

Remarks. Use the Anchor property to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.

Which setting of the dock property causes the control to fill its form or container control?

The docking mode can be any side of the control's container, or set to fill the remaining space of the container.

What is anchor in Windows form?

Anchor refers to the position a control has relative to the edges of the form. A textbox, for example, that is anchored to the left edge of a form will stay in the same position as the form is resized. Docking refers to how much space you want the control to take up on the form.

Which control you would select to place the child control in top left right and bottom using dock property?

DockPanel defines an area to arrange child elements relative to each other, either horizontally or vertically. With DockPanel you can easily dock child elements to top, bottom, right, left and center using the Dock property.


1 Answers

Try to use this

 foreach (Control item in this.Controls)  {       item.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);  } 
like image 141
Stecya Avatar answered Sep 22 '22 01:09

Stecya