Alex Rivera | Logout

C# Anchor property doesn't seem to work

Asked 2009-10-21T10:46:59.590
10

I added some controls to my form and changed Anchor property how I'd expect this to work, but when I resize the form at the runtime, the controls stay at the same place.

For example, I have two buttons in bottom right corner of a form - they are on the form, no containers or anything like that. Anchor = Bottom, Right. FormBorderStyle = Sizable. But when I drag-resize the form while running, buttons do not move.

Am I missing something?

c# 2005

Edit
Report

1 Answer

1

I have the same problem in VS11 Beta. I used anchors a lot of times and it always worked properly, but now I can't understand what's going on with them and not only - dock fill doesn't work too! (no auto size or dock properties are used)

P.S. (after 40 minutes) Now it look's like I've found the problem: I have Resize event listener for PictureBox and I create new Image for new picturebox size in onResize handler. When I remove new image creation everything works!

Now I use SizeChanged event and in this event handler I create new image. So I think I shouldn't change sender object until Resize finished.

answered 2012-08-25T21:20:39.707

Your Answer