I added a Button on my form, I want to arrange it's location precisely to the pixel on the form. Does anyone know how I can do that? Thanks in advance.

Recommended Answers

All 8 Replies

Try using the .Top and .Left properties of the control. You can make it relative to the form by using the buttons .Width and .Height members as well as the form's width and height. Although anchoring and docking will keep these ratios even for you.

MyButton.Location = new Point(11,11); would position the upper left part of your button at the point 11,11

I'm sorry I didn't make it clear, I want to drag the control pixel at a time, right now when I move the control by dragging the mouse, it move in a large gap.

Not through coding. In the Form Designer, I want to drag any controls but only a pixel right now when I drag it drag in a large gap.

O that. Look in Tools menu Options, under Windows Form Designer General for settings of the Grid, under Layout Settings.

You should be able to move them pixel by pixel by default. However, Visual Studio will try to auto-align it with other controls (middles, tops and bottoms). You can disable this by holding the ALT key while dragging a control.

commented: Thanks for the tip! +15

Thanks guys, that would do it. I remembered I can do that when I was doing VB3 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.