本文整理汇总了C#中System.Windows.Forms.TabControl.PointToClient方法的典型用法代码示例。如果您正苦于以下问题:C# TabControl.PointToClient方法的具体用法?C# TabControl.PointToClient怎么用?C# TabControl.PointToClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TabControl
的用法示例。
在下文中一共展示了TabControl.PointToClient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ux_tabcontrolDragDropEvent
public void ux_tabcontrolDragDropEvent(TabControl ux_tabcontrolDataview, DragEventArgs e)
{
if (e.AllowedEffect == e.Effect)
{
// Convert the mouse coordinates from screen to client...
System.Drawing.Point ptClientCoord = ux_tabcontrolDataview.PointToClient(new System.Drawing.Point(e.X, e.Y));
int destinationTabPageIndex = -1;
int originalTabPageIndex = -1;
// Attempt to find where the tabpage should be dropped...
for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++)
{
//if (ux_tabcontrolDataview.TabPages[i] == e.Data.GetData(typeof(TabPage))) originalTabPageIndex = i;
if (ux_tabcontrolDataview.TabPages[i] == e.Data.GetData("System.Windows.Forms.TabPage")) originalTabPageIndex = i;
if (ux_tabcontrolDataview.GetTabRect(i).Contains(ptClientCoord)) destinationTabPageIndex = i;
}
// Now create a copy of the tabpage that is being moved so that
// you can remove the orginal and insert the copy at the right spot...
TabPage newTabPage = new TabPage();
//newTabPage.Text = ((TabPage)e.Data.GetData(typeof(TabPage))).Text;
newTabPage.Text = ((TabPage)e.Data.GetData("System.Windows.Forms.TabPage")).Text;
//newTabPage.Tag = ((TabPage)e.Data.GetData(typeof(TabPage))).Tag;
newTabPage.Tag = ((TabPage)e.Data.GetData("System.Windows.Forms.TabPage")).Tag;
ux_tabcontrolDataview.TabPages.Insert(destinationTabPageIndex, newTabPage);
ux_tabcontrolDataview.SelectTab(destinationTabPageIndex);
if (originalTabPageIndex < destinationTabPageIndex)
{
ux_tabcontrolDataview.TabPages.RemoveAt(originalTabPageIndex);
}
else
{
ux_tabcontrolDataview.TabPages.RemoveAt(originalTabPageIndex + 1);
}
}
}
示例2: ux_tabcontrolDragOverEvent
public void ux_tabcontrolDragOverEvent(TabControl ux_tabcontrolDataview, DragEventArgs e)
{
// Convert the mouse coordinates from screen to client...
System.Drawing.Point ptClientCoord = ux_tabcontrolDataview.PointToClient(new System.Drawing.Point(e.X, e.Y));
//int destinationTabPage = ux_tabcontrolDataview.TabPages.IndexOf((TabPage)e.Data.GetData(typeof(TabPage)));
if (e.Data.GetDataPresent("System.Windows.Forms.TabPage"))
{
int destinationTabPage = ux_tabcontrolDataview.TabPages.IndexOf((TabPage)e.Data.GetData("System.Windows.Forms.TabPage"));
// Attempt to find the tabpage that is being dragged over...
for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++)
{
if (ux_tabcontrolDataview.GetTabRect(i).Contains(ptClientCoord)) destinationTabPage = i;
}
////if (e.Data.GetDataPresent(typeof(TabPage)) &&
//if (e.Data.GetDataPresent("System.Windows.Forms.TabPage") &&
////ux_tabcontrolDataview.TabPages[destinationTabPage] != (TabPage)e.Data.GetData(typeof(TabPage)) /* &&
//ux_tabcontrolDataview.TabPages[destinationTabPage] != (TabPage)e.Data.GetData("System.Windows.Forms.TabPage") /* &&
// destinationTabPage != ux_tabcontrolDataview.TabPages.IndexOfKey("ux_tabpageDataviewNewTab")*/
// )
if (ux_tabcontrolDataview.TabPages[destinationTabPage] != (TabPage)e.Data.GetData(typeof(TabPage)))
{
e.Effect = DragDropEffects.Move;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
示例3: getHoverTabIndex
private int getHoverTabIndex(TabControl tc)
{
for (int i = 0; i < tc.TabPages.Count; i++)
{
if (tc.GetTabRect(i).Contains(tc.PointToClient(Cursor.Position)))
return i;
}
return -1;
}