Anchoring question

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?
 
J

Jeff Gaines

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?
 
M

Michael C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top