0

Как отобразить кнопку поверх остальных элементов или поверх tabPage или поверх tabControl?

_tabPages.Add(new System.Windows.Forms.TabPage());
            _tabPages[countOfGraphs - 1].Location = new System.Drawing.Point(4, 22);
            _tabPages[countOfGraphs - 1].Name = "_tabPages" + countOfGraphs;
            _tabPages[countOfGraphs - 1].Padding = new System.Windows.Forms.Padding(3);
            _tabPages[countOfGraphs - 1].Size = new System.Drawing.Size(930, 440);
            _tabPages[countOfGraphs - 1].TabIndex = countOfGraphs;
            _tabPages[countOfGraphs - 1].Text = "File_" + countOfGraphs+"    ";
            _tabPages[countOfGraphs - 1].SendToBack();
            _tabPages[countOfGraphs - 1].UseVisualStyleBackColor = false;
            _tabPages[countOfGraphs - 1].Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
          | System.Windows.Forms.AnchorStyles.Left)
          | System.Windows.Forms.AnchorStyles.Right)));
            tabControl2.Controls.Add(_tabPages[countOfGraphs - 1]);


            buttonX.Add(new System.Windows.Forms.Button());
            //this.buttonCut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            buttonX[countOfGraphs - 1].Location = new System.Drawing.Point(40, -20);
            buttonX[countOfGraphs - 1].Name = "buttonX";
            buttonX[countOfGraphs - 1].Size = new System.Drawing.Size(30, 24);
            buttonX[countOfGraphs - 1].TabIndex = 8;
            buttonX[countOfGraphs - 1].Text = "><";
            buttonX[countOfGraphs - 1].BringToFront();
            buttonX[countOfGraphs - 1].Show();
            buttonX[countOfGraphs - 1].Visible = true;
            buttonX[countOfGraphs - 1].BackColor = Color.IndianRed;
            buttonX[countOfGraphs - 1].UseVisualStyleBackColor = false;
            //buttonX[countOfGraphs - 1].Click += new System.EventHandler(this.buttonCut_Click);
            _tabPages[countOfGraphs - 1].Controls.Add(buttonX[countOfGraphs - 1]);
2
  • кнопка должна относиться к TabPage, TabControl или форме? в котором из указанных контейнеров ее надо разместить и отобразить поверх других?
    – rdorn
    11 фев 2016 в 22:28
  • @rdorn поверх tabpages
    – SVD102
    12 фев 2016 в 3:51

1 ответ 1

1

докс.майкрософт.ком подсказывает:

To layer controls programmatically Use the BringToFront and SendToBack methods to manipulate the z-order of the controls.

For example, if a TextBox control, txtFirstName, is underneath another control and you want to have it on top, use the following code:

txtFirstName.BringToFront();  

Ваш ответ

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

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