Anchoring question

  • Thread starter Thread starter Elmo Watson
  • Start date Start date
E

Elmo Watson

I need to add some textboxes to a form, programmatically
Dim ctl As New System.Windows.Forms.TextBox
ctl.Top = iTop
Me.Controls.Add(ctl)
iTop = iTop + 25

I need them to anchor on the left and the right - but I can't seem to find
how to do it

When I try to programmatically anchor them, I only get one choice, if I do
it twice:
ctl.Anchor = AnchorStyles.Left
ctl.Anchor = AnchorStyles.right

Only the second one 'takes'

How can I programmatically anchor them so that they'll stretch all the way
across the form, from left to right?
 
When I try to programmatically anchor them, I only get one choice, if I do
it twice:
ctl.Anchor = AnchorStyles.Left
ctl.Anchor = AnchorStyles.right

In C# it would be:

ctl.Anchor = AnchorStyles.Left | AnchorStyles.right;

Although I guess it would be Left | Top or Right | Top rather than Left |
Right.

The sign | means or - is there an 'or' in VB?
 
Jeff Gaines said:
In C# it would be:

ctl.Anchor = AnchorStyles.Left | AnchorStyles.right;

Although I guess it would be Left | Top or Right | Top rather than Left |
Right.

The sign | means or - is there an 'or' in VB?

| = Or
|| = OrElse

Michael
 
Back
Top