Windows forms form location

Form. Location Свойство

Определение

Получает или задает объект Point, который представляет собой верхний левый угол формы Form в экранных координатах. Gets or sets the Point that represents the upper-left corner of the Form in screen coordinates.

Значение свойства

Объект Point, который представляет собой верхний левый угол формы Form в экранных координатах. The Point that represents the upper-left corner of the Form in screen coordinates.

Комментарии

Point — Это структура, которая означает, что это тип значения. Point is a structure, which means that it is a value type. При обращении к свойству в службах Point возвращается копия свойства. If you access a property in Point, a copy of the property is returned. Таким образом, изменение X свойств или, Y Point возвращаемых из Location свойства, не повлияет на Left Right значения свойств,, Top или Bottom Form . Therefore, changing the X or Y properties of the Point returned from the Location property will not affect the Left, Right, Top, or Bottom property values of the Form. Чтобы настроить эти свойства, установите каждое значение свойства по отдельности или задайте для Location свойства новое Point . To adjust these properties, set each property value individually, or set the Location property with a new Point.

LocationСвойство получает или задает Location свойство Control базового класса и присваивает Bindable свойству значение true . The Location property gets or sets the Location property of the Control base class, and sets the Bindable property to true .

Control. Location Свойство

Определение

Возвращает или задает координаты левого верхнего угла элемента управления относительно левого верхнего угла его контейнера. Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

Значение свойства

Объект Point, представляющий левый верхний угол элемента управления относительно левого верхнего угла контейнера. The Point that represents the upper-left corner of the control relative to the upper-left corner of its container.

Примеры

В следующем примере кода создается GroupBox и задаются некоторые общие свойства. The following code example creates a GroupBox and sets some of its common properties. В примере создается TextBox и задается Location в поле группы. The example creates a TextBox and sets its Location within the group box. Затем задается Text свойство поля группы и закрепляет поле группы в верхней части формы. Next, it sets the Text property of the group box, and docks the group box to the top of the form. Наконец, он отключает поле группы, присвоив Enabled свойству значение false , которое приводит к отключению всех элементов управления, содержащихся в поле группы. Lastly, it disables the group box by setting the Enabled property to false , which causes all controls contained within the group box to be disabled.

Читайте также:  Создание backup windows server

Комментарии

Поскольку Point класс является типом значения ( Structure в Visual Basic struct в Visual C#), он возвращается по значению, что означает, что доступ к свойству возвращает копию верхней левой точки элемента управления. Because the Point class is a value type ( Structure in Visual Basic, struct in Visual C#), it is returned by value, meaning accessing the property returns a copy of the upper-left point of the control. Таким образом, Настройка X свойств или, Y Point возвращаемых из этого свойства, не влияет на Left Right Top значения свойств,, или Bottom элемента управления. So, adjusting the X or Y properties of the Point returned from this property will not affect the Left, Right, Top, or Bottom property values of the control. Чтобы настроить эти свойства, задавайте каждое значение свойства отдельно или задайте для Location свойства новое Point . To adjust these properties set each property value individually, or set the Location property with a new Point.

Если Control Form свойство —, Location значение свойства представляет левый верхний угол Form в координатах экрана. If the Control is a Form, the Location property value represents the upper-left corner of the Form in screen coordinates.

Как располагать элементы управления на Windows Forms How to: Position controls on Windows Forms

Чтобы разместить элементы управления, используйте конструктор Windows Forms в Visual Studio или укажите Location свойство. To position controls, use the Windows Forms Designer in Visual Studio or specify the Location property.

Размещение элемента управления в области конструктора конструктор Windows Forms Position a control on the design surface of the Windows Forms Designer

В Visual Studio перетащите элемент управления в соответствующее место с помощью мыши. In Visual Studio, drag the control to the appropriate location with the mouse.

Выберите элемент управления и переместите его с помощью клавиш со СТРЕЛКАми, чтобы более точно расположить его. Select the control and move it with the ARROW keys to position it more precisely. Кроме того, линии привязки помогают точно разместить элементы управления в форме. Also, snaplines assist you in placing controls precisely on your form. Дополнительные сведения см. в разделе Пошаговое руководство. Упорядочивание элементов управления в Windows Forms с помощью линий привязки. For more information, see Walkthrough: Arranging Controls on Windows Forms Using Snaplines.

Читайте также:  Как установить komodo edit windows

Размещение элемента управления с помощью окно свойств Position a control using the Properties window

В Visual Studio выберите элемент управления, который требуется разместить. In Visual Studio, select the control you want to position.

В окне Свойства введите значения для Location свойства, разделенные запятыми, чтобы разместить элемент управления в контейнере. In the Properties window, enter values for the Location property, separated by a comma, to position the control within its container.

Первое число (X) — это расстояние от левой границы контейнера; второе число (Y) — это расстояние от верхней границы области контейнера, измеряемое в пикселях. The first number (X) is the distance from the left border of the container; the second number (Y) is the distance from the upper border of the container area, measured in pixels.

Можно развернуть свойство, Location чтобы ввести значения X и Y по отдельности. You can expand the Location property to type the X and Y values individually.

Размещение элемента управления программным способом Position a control programmatically

Присвойте Location свойству элемента управления значение Point . Set the Location property of the control to a Point.

Измените координату X расположения элемента управления с помощью Left подсвойства. Change the X coordinate of the control’s location using the Left subproperty.

Программное увеличение расположения элемента управления Increment a control’s location programmatically

Задайте Left подсвойство, чтобы увеличить координату X элемента управления. Set the Left subproperty to increment the X coordinate of the control.

Используйте Location свойство, чтобы одновременно задать координаты X и Y элемента управления. Use the Location property to set a control’s X and Y positions simultaneously. Чтобы задать расположение по отдельности, используйте Left подсвойство (X) или Top (Y) элемента управления. To set a position individually, use the control’s Left (X) or Top (Y) subproperty. Не пытайтесь неявно задать координаты X и Y Point структуры, представляющей расположение кнопки, так как эта структура содержит копию координат кнопки. Do not try to implicitly set the X and Y coordinates of the Point structure that represents the button’s location, because this structure contains a copy of the button’s coordinates.

Как изменить свойство Location у кнопки

Не могу изменить свойство Location одной из форм
стоит открыть ее свойства опять — снова стоят нули. исправил, сохранил, открыл — нули. причем.

Читайте также:  Windows serials and cracks

Как изменить свойство Visible/Enable у кнопки на форме по команде из UserControl и почему не срабатывает логическое И?
Всем привет. Вроде уже не нуб в шарпе, но тут с элементарным запарился. Вопросов 2 : 1. Есть.

Изменить свойство Location формы во время ее работы
Можно ли программно(т.е во время работы программы, она сама например ползла налево) менять свойство.

Изменить свойство Text кнопки
здравствуйте друзья я начал разбираться в С# буквально два дня назад. так што если я спрашиваю.

И почему мы не можем просто писать button, а нужно писать mybutton, опять же чёрт.

Добавлено через 2 минуты

Мне так захотелось.

Тематические курсы и обучение профессиям онлайн
Профессия‌ С#-разработчик‌ (Skillbox)
Архитектор ПО (Skillbox)
Профессия Тестировщик (Skillbox)

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Изменить через триггер свойство кнопки
Пробую через тригер изменить , например статус кнопки( в идеале подсказать как реализовать для.

Свойство формы Location, или как рассчитать начальную позицию формы
Вообще, есть 2 формы, одна посередине другая рядом с ней стоит с права (или в правом верхнем углу).

Изменять свойство Location пропорционально размеру изображений
Здравствуйте! Есть panel, на которой располагаются 10 значков(pictureBox) по длине всей полоски.

Какое свойство нового окна задается параметром location?
Какое свойство нового окна задается параметром location? (Отметьте один правильный вариант.

How to position the opening form at specific location in C# Windows Forms?

The Location property in the form is set to 0,0 (Properties Window). However, the form doesn’t open at the specified location. Am I missing something?

4 Answers 4

You need to set StartPosition to manual to make the form set start position to the value in Location Property.

Intelisense Summary for FormStartPosition.Manual

The position of the form is determined by the System.Windows.Forms.Control.Location property.

By default the start position is set to be WindowsDefaultLocation which will cause the form to ignore the location you are setting. To easily have the set location enforced, change the StartPosition to Manual.

Setting the Location at 0,0 has no effect if you forget to set StartPosition to FormStartPosition.Manual

This property enables you to set the starting position of the form when it is displayed at run time. The form’s position can be specified manually by setting the Location property or use the default location specified by Windows. You can also position the form to display in the center of the screen or in the center of its parent form for forms such as multiple-document interface (MDI) child forms.

Оцените статью