拖动和分离选项卡 [英] Drag and detach tabpages

查看:89
本文介绍了拖动和分离选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个选项卡控件上有多个选项卡,我想知道是否有人知道我如何编程一种方法将选项卡控件从选项卡控件中拖动到自己的窗体"中....将选项卡控件拉开?

I have several tabpages on a single tab control and I was wondering if anyone out there knows how I can program a way to drag tabpages off the tab control and into their own "form"....pulling the tabcontrol apart?

我正在使用vb.net,确实找到了许多方法来移动tabcontrol上的tabpage的顺序,但是不知道如何真正分离tabtab并将其\拖到屏幕上的其他位置?

I'm using vb.net and did find many ways to move the order of tabpages on the tabcontrol but non om how to actually detach the tabpage and place \ drag it elsewhere on the screen?

推荐答案

假设使用WinForms,基本上必须创建一个新的Form和一个新的TabControl来容纳计划移动的TabPage.

Assuming WinForms, essentially you have to create a new Form and a new TabControl to house the TabPage you plan on moving.

最简单的形式:

Private Sub TabControl1_MouseMove(sender As Object, e As MouseEventArgs) Handles TabControl1.MouseMove
  If (e.Button = MouseButtons.Left) Then
    TabControl1.DoDragDrop(TabControl1.SelectedTab, DragDropEffects.Move)
  End If
End Sub

Private Sub TabControl1_GiveFeedback(sender As Object, e As GiveFeedbackEventArgs) Handles TabControl1.GiveFeedback
  e.UseDefaultCursors = False
End Sub

Private Sub TabControl1_QueryContinueDrag(sender As Object, e As QueryContinueDragEventArgs) Handles TabControl1.QueryContinueDrag
  If Control.MouseButtons <> MouseButtons.Left Then
    e.Action = DragAction.Cancel
    Dim f As New Form
    f.Size = New Size(400, 300)
    f.StartPosition = FormStartPosition.Manual
    f.Location = MousePosition
    Dim tc As New TabControl
    tc.Dock = DockStyle.Fill
    tc.TabPages.Add(TabControl1.SelectedTab)
    f.Controls.Add(tc)
    f.Show()
    Me.Cursor = Cursors.Default
  Else
    e.Action = DragAction.Continue
    Me.Cursor = Cursors.Help
  End If
End Sub

这篇关于拖动和分离选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆