1

Здраствуйте. Помогите с добавлением кнопок. Это нужно для дальнейшей работы.введите сюда описание изображения

Я знаю, что добавить - Button but = new Button(); .... Controls.Add(but); Отступ, вот, что нужно.

1 ответ 1

1
int offsetY = 5;
int x = 0;
int y = 0;
int index = 1;
foreach(Button oldB in Controls.OfType<Button>()) 
{
  x = oldB.Location.X;
  y = Math.Max(y, oldB.Location.Y + oldB.Height);
  index++;
}

Button b = new Button();
b.Location = new Point(x, y + offsetY);
b.Text = "Button " + index.ToString();
Controls.Add(b);
2
  • Спасибо, очень помогли. 6 фев 2019 в 12:40
  • @IODAYSIProJect Пожалуйста. Успехов!
    – user176262
    6 фев 2019 в 13:47

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.