Answer the question
In order to leave comments, you need to log in
Managed tabs like in Microsoft Excel?
Hello, Happy New Year. Who can suggest or give examples on how to make managed tabs in Visual Studio in Basic the way it is implemented in Excel? When you click on the "+" a new tab appears, and the "+" itself is shifted to the next position relative to the new tab and, accordingly, if possible, RMB-> Delete tab.
Excel:
VS Studio Basic:
Answer the question
In order to leave comments, you need to log in
On the form: TabControl - TabControl1, ContextMenuStrip - ContextMenuStrip1 with Delete item
Private Sub TabControl1_Selected(sender As Object, e As TabControlEventArgs) Handles TabControl1.Selected 'событие Selected при выборе вкладки
If (e.TabPage.Text = "+") Then 'если вкладка имеет текст +
e.TabPage.Text = "TabPage" + TabControl1.TabPages.Count.ToString() 'переименовываем текущую вкладку
TabControl1.TabPages.Add("+") 'добавляем новую вкладку
End If
End Sub
Private Sub TabControl1_MouseUp(sender As Object, e As MouseEventArgs) Handles TabControl1.MouseUp 'событие MouseUp при клике на TabControl1
If (e.Button = MouseButtons.Right) Then 'Если нажатие ПКМ
ContextMenuStrip1.Show(MousePosition, ToolStripDropDownDirection.Right) 'выводим по координатам клика ContextMenuStrip1
End If
End Sub
Private Sub DeleteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DeleteToolStripMenuItem.Click 'событие Click при нажатии на кнопку Delete в ContextMenuStrip1
TabControl1.TabPages.Remove(TabControl1.SelectedTab) 'Удаляем ОТКРЫТУЮ вкладку
End Sub
Thank you very much for your reply. There is one more nuance - after adding the 3rd tab, the ones following it change the background to the one when the object is inactive. Is this how it should be or do I need to set something in the properties of the TabControl?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question