private void TSMI_CtxtTab_RenameClick(object sender, EventArgs e) { if (!(ContextTabPage == null)) { int PageIndex = GetPageIndex(ContextTabPage); if (PageIndex != -1) { Rectangle TabRec = Tab_Viewers.GetTabRect(PageIndex); TextBox TxtNewName = new TextBox(); TxtNewName.KeyDown += new KeyEventHandler(TxtNewName_KeyDown); TxtNewName.LostFocus += new EventHandler(TxtNewName_LostFocus); TxtNewName.Location = this.PointToScreen(TabRec.Location); TxtNewName.Size = new Size(TabRec.Width * 2, TabRec.Height); TxtNewName.Text = ContextTabPage.Text; TxtNewName.SelectAll(); this.Controls.Add(TxtNewName); TxtNewName.BringToFront(); TxtNewName.Focus(); } } }
private TabPage GetTabPageAtPosition(Point Location) { for (int i = 0; i < Tab_Viewers.TabPages.Count; i++) { Rectangle TabRec = Tab_Viewers.GetTabRect(i); if ((Location.X >= TabRec.Left && Location.X < TabRec.Left + TabRec.Width) && (Location.Y >= TabRec.Top && Location.Y < TabRec.Top + TabRec.Height)) { return(Tab_Viewers.TabPages[i]); } } return(null); }