Board index » Visual Studio » Dynamic Button Anchor Problem

Dynamic Button Anchor Problem

Visual Studio201
FYI: This may be a duplicate posting. It appears my previous posts have

failed.



I have a form that displays nothing on it except a few buttons. When the

form is loaded it is dynamically displays additional buttons. Each customer

who has an open order has a button created for them. The buttons are created

during the Form_Load event.



The problem Iâ??m having is that all of my existing buttons disappear when the

form loads. Being frustrated with this behavior I came up with a solution. My

solution was to just go ahead and dynamically create my regular buttons such

as btnExit, btnOpen and btnPrint dynamically just like the other buttons were

created. During my first test everything was working great. I used the

following code to create the buttons.



Dim btn1 As New Button

' Create the Exit Button.

btn1.Location = New System.Drawing.Point(888, 603)

btn1.Margin = New System.Windows.Forms.Padding(2)

btn1.Name = "btnExit"

btn1.Size = New System.Drawing.Size(117, 66)

btn1.TabIndex = 5

btn1.Text = "Exit"

Controls.Add(btn1)

AddHandler btn1.Click, AddressOf btnExit_Click



The code created the buttons just as I wanted. But, when I ran my test I

realized I forgot to set one property and that was the anchor property

because when I resized the form the button did not stay anchored as I need it

to. So, I added the following line of code to anchor the buttons to the lower

right corner of the form.



btn1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or

System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)



Now, all of the sudden my buttons are not showing up again. After further

testing I discovered that if I have an existing or a dynamic button with the

anchor properties set they will not appear on the form at all.



My assumption is the buttons are being created except they are not being

displayed on the form.



Why is this happening and if theres are reason for this what must I do to

resolve the problem?



Thanks


-
 

Re:Dynamic Button Anchor Problem

Your previous posts have not 'failed'. This must be the fourth or

fifth one I have seen.



On Tue, 23 Oct 2007 08:39:01 -0700, Greg

<AccessVBAnet@newsgroups.nospam>wrote:



Quote
FYI: This may be a duplicate posting. It appears my previous posts have

failed.



I have a form that displays nothing on it except a few buttons. When the

form is loaded it is dynamically displays additional buttons. Each customer

who has an open order has a button created for them. The buttons are created

during the Form_Load event.



The problem I?m having is that all of my existing buttons disappear when the

form loads. Being frustrated with this behavior I came up with a solution. My

solution was to just go ahead and dynamically create my regular buttons such

as btnExit, btnOpen and btnPrint dynamically just like the other buttons were

created. During my first test everything was working great. I used the

following code to create the buttons.



Dim btn1 As New Button

' Create the Exit Button.

btn1.Location = New System.Drawing.Point(888, 603)

btn1.Margin = New System.Windows.Forms.Padding(2)

btn1.Name = "btnExit"

btn1.Size = New System.Drawing.Size(117, 66)

btn1.TabIndex = 5

btn1.Text = "Exit"

Controls.Add(btn1)

AddHandler btn1.Click, AddressOf btnExit_Click



The code created the buttons just as I wanted. But, when I ran my test I

realized I forgot to set one property and that was the anchor property

because when I resized the form the button did not stay anchored as I need it

to. So, I added the following line of code to anchor the buttons to the lower

right corner of the form.



btn1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or

System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)



Now, all of the sudden my buttons are not showing up again. After further

testing I discovered that if I have an existing or a dynamic button with the

anchor properties set they will not appear on the form at all.



My assumption is the buttons are being created except they are not being

displayed on the form.



Why is this happening and if theres are reason for this what must I do to

resolve the problem?



Thanks

-

Re:Dynamic Button Anchor Problem

My aplogies for that. It appeared on my side as though the posts did not go

through.



"Jack Jackson" wrote:



Quote
Your previous posts have not 'failed'. This must be the fourth or

fifth one I have seen.



On Tue, 23 Oct 2007 08:39:01 -0700, Greg

<AccessVBAnet@newsgroups.nospam>wrote:



>FYI: This may be a duplicate posting. It appears my previous posts have

>failed.

>

>I have a form that displays nothing on it except a few buttons. When the

>form is loaded it is dynamically displays additional buttons. Each customer

>who has an open order has a button created for them. The buttons are created

>during the Form_Load event.

>

>The problem Iâ??m having is that all of my existing buttons disappear when the

>form loads. Being frustrated with this behavior I came up with a solution. My

>solution was to just go ahead and dynamically create my regular buttons such

>as btnExit, btnOpen and btnPrint dynamically just like the other buttons were

>created. During my first test everything was working great. I used the

>following code to create the buttons.

>

>Dim btn1 As New Button

>' Create the Exit Button.

>btn1.Location = New System.Drawing.Point(888, 603)

>btn1.Margin = New System.Windows.Forms.Padding(2)

>btn1.Name = "btnExit"

>btn1.Size = New System.Drawing.Size(117, 66)

>btn1.TabIndex = 5

>btn1.Text = "Exit"

>Controls.Add(btn1)

>AddHandler btn1.Click, AddressOf btnExit_Click

>

>The code created the buttons just as I wanted. But, when I ran my test I

>realized I forgot to set one property and that was the anchor property

>because when I resized the form the button did not stay anchored as I need it

>to. So, I added the following line of code to anchor the buttons to the lower

>right corner of the form.

>

>btn1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or

>System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)

>

>Now, all of the sudden my buttons are not showing up again. After further

>testing I discovered that if I have an existing or a dynamic button with the

>anchor properties set they will not appear on the form at all.

>

>My assumption is the buttons are being created except they are not being

>displayed on the form.

>

>Why is this happening and if theres are reason for this what must I do to

>resolve the problem?

>

>Thanks



-

Re:Dynamic Button Anchor Problem

Hi Greg,



Then, can you create a little sample project to demonstrate this behavior?

I have never heard of such behaviors before, so we need a local reproduce

for investigation.



Note: you'd better get rid of the database dependency for the sample

project. Thanks.



Best regards,

Jeffrey Tan

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to

msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx">msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx

ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues

where an initial response from the community or a Microsoft Support

Engineer within 1 business day is acceptable. Please note that each follow

up response may take approximately 2 business days as the support

professional working with you may need further investigation to reach the

most efficient resolution. The offering is not appropriate for situations

that require urgent, real-time or phone-based interactions or complex

project analysis and dump analysis issues. Issues of this nature are best

handled working with a dedicated Microsoft Support Engineer by contacting

Microsoft Customer Support Services (CSS) at

msdn.microsoft.com/subscriptions/support/default.aspx.">msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.





-

Re:Dynamic Button Anchor Problem

I should be able to send you a sample next week.



""Jeffrey Tan[MSFT]"" wrote:



Quote
Hi Greg,



Then, can you create a little sample project to demonstrate this behavior?

I have never heard of such behaviors before, so we need a local reproduce

for investigation.



Note: you'd better get rid of the database dependency for the sample

project. Thanks.



Best regards,

Jeffrey Tan

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to

msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx">msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx

ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues

where an initial response from the community or a Microsoft Support

Engineer within 1 business day is acceptable. Please note that each follow

up response may take approximately 2 business days as the support

professional working with you may need further investigation to reach the

most efficient resolution. The offering is not appropriate for situations

that require urgent, real-time or phone-based interactions or complex

project analysis and dump analysis issues. Issues of this nature are best

handled working with a dedicated Microsoft Support Engineer by contacting

Microsoft Customer Support Services (CSS) at

msdn.microsoft.com/subscriptions/support/default.aspx.">msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.







-

Re:Dynamic Button Anchor Problem

Hi Greg,



Thanks for your feedback.



Ok, if you managed to create a sample for this problem, please feel free to

attach in newsgroup or send it to me at: jetan@online.microsoft.com(remove

"online."). Thanks.



Best regards,

Jeffrey Tan

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to

msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx">msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx

ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues

where an initial response from the community or a Microsoft Support

Engineer within 1 business day is acceptable. Please note that each follow

up response may take approximately 2 business days as the support

professional working with you may need further investigation to reach the

most efficient resolution. The offering is not appropriate for situations

that require urgent, real-time or phone-based interactions or complex

project analysis and dump analysis issues. Issues of this nature are best

handled working with a dedicated Microsoft Support Engineer by contacting

Microsoft Customer Support Services (CSS) at

msdn.microsoft.com/subscriptions/support/default.aspx.">msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.





-

Re:Dynamic Button Anchor Problem

Hi Greg,



Have you managed to create a sample project? If you still need any help,

please feel free to tell me, thanks.



Best regards,

Jeffrey Tan

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to

msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx">msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx

ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues

where an initial response from the community or a Microsoft Support

Engineer within 1 business day is acceptable. Please note that each follow

up response may take approximately 2 business days as the support

professional working with you may need further investigation to reach the

most efficient resolution. The offering is not appropriate for situations

that require urgent, real-time or phone-based interactions or complex

project analysis and dump analysis issues. Issues of this nature are best

handled working with a dedicated Microsoft Support Engineer by contacting

Microsoft Customer Support Services (CSS) at

msdn.microsoft.com/subscriptions/support/default.aspx.">msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.





-