GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEV
,
WEBDEV
e
WINDEV Mobile
Inicio
|
Mensagens recentes
|
Conecte-se...
|
Disconnect
|
Português
Inicio
→
WINDEV 26
→
[WD25] drag-and-drop naar een TAB-control
[WD25] drag-and-drop naar een TAB-control
Iniciado por Stefan, out., 11 2021 3:52 PM - 2 respostas
Conecte-se…
Stefan
#1
Membro registado
7 mensagems
Publicado em outubro, 11 2021 - 3:52 PM
Hallo,
Heeft iemand enig idee hoe ik het voor elkaar kan krijgen om drag-and-drop werkend te krijgen naar een TAB-control?
Ik wil een afspraak uit een planning-control naar een TAB-control slepen en als ik deze loslaat (drop) wil ik weten op welk tabblad ik de drop uitgevoerd heb en dan een stukje code uitvoeren. Probleem is voorlopig dat drag-and-drop helemaal niets activeert voor een TAB-control. Dus bij het hover'en boven de TAB-control blijft de cursor op "Verboden" staan en als ik een drop uitvoer gebeurt er ook helemaal niets. Ik heb de volgende DNDEvents gedefinieerd in de initialisatie van het TAB-control:
DnDEvent(UnknownDragOverTAB, TAB_SLACHTERIJ, dndDragOver)
DnDEvent(PlanningDroppedOnTAB, TAB_SLACHTERIJ, dndDrop)
Traces in die procedures doen helemaal niets. Nu is automatic drag-and-drop ook niet instelbaar, terwijl dat b.v. bij een table-control wel mogelijk is door een vinkje te zetten in, ik geloof, de details tab van de table-control. Dus mogelijk is Drag-and-drop in het geheel niet mogelijk naar een TAB-control.
--
Regards, Stefan
Denunciar
0
0
SandraLewisFrin
#2
Membro registado
6 mensagems
Publicado em março, 11 2022 - 8:34 AM
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace DraggableTabControl
{
[ToolboxBitmap(typeof(DraggableTabControl))]
///
/// Summary description for DraggableTabPage.
///
public class DraggableTabControl : System.Windows.Forms.TabControl
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public DraggableTabControl()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
}
#endregion
protected override void OnDragOver(System.Windows.Forms.DragEventArgs e)
{
base.OnDragOver(e);
Point pt = new Point(e.X, e.Y);
//We need client coordinates.
pt = PointToClient(pt);
//Get the tab we are hovering over.
TabPage hover_tab = GetTabPageByTab(pt);
//Make sure we are on a tab.
if(hover_tab != null)
{
//Make sure there is a TabPage being dragged.
if(e.Data.GetDataPresent(typeof(TabPage)))
{
e.Effect = DragDropEffects.Move;
TabPage drag_tab = (TabPage)e.Data.GetData(typeof(TabPage));
int item_drag_index = FindIndex(drag_tab);
int drop_location_index= FindIndex(hover_tab);
//Don't do anything if we are hovering over ourself.
if(item_drag_index ! = drop_location_index) {
ArrayList pages = new ArrayList();
//Put all tab pages into an array.
for(int i = 0; i < TabPages.Count; i++)
{
//Except the one we are dragging.
if(i != item_drag_index)
pages.Add(TabPages[i]);
}
//Now put the one we are dragging it at the proper location.
pages.Insert(drop_location_index, drag_tab);
//Make them all go away for a nanosec.
TabPages.Clear();
//Add them all back in.
TabPages.AddRange((TabPage[])pages.ToArray(typeof(TabPage)));
//Make sure the drag tab is selected.
SelectedTab = drag_tab;
}
}
}
else
{
e.Effect = DragDropEffects.None;
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
Point pt = new Point(e.X, e.Y);
TabPage tp = GetTabPageByTab(pt);
if(tp != null)
{
DoDragDrop(tp, DragDropEffects.All);
}
}
///
/// Finds the TabPage whose tab is contains the given point.
///
/// The point (given in client coordinates) to look for a TabPage.
/// The TabPage whose tab is at the given point (null if there isn't one).
private TabPage GetTabPageByTab(Point pt)
{
TabPage tp =
null;
for(int i =
0; i < TabPages.Count; i++)
{
if(GetTabRect(i).Contains(pt))
{
tp = TabPages[i];
break;
}
}
return tp;
}
///
/// Loops over all the TabPages to find the index of the given TabPage.
///
/// The TabPage we want the index for.
/// The index of the given TabPage(-1 if it isn't found.)
private int FindIndex(TabPage page)
{
for(int i = 0; i < TabPages.Count; i++)
{
if(TabPages[i] == page)
return i;
}
return -1;
}
}
}
Denunciar
0
0
SandraLewisFrin
#3
Membro registado
6 mensagems
Publicado em abril, 05 2022 - 12:10 PM
Yes, it is. As long as I understand you correctly:
Let's say you have 3 tabs open: Tab 1, Tab 2 and Tab 3. And now you want to move Tab 1 between Tab 2 and Tab 3. Simply grab Tab 1 and drag it between Tab 2 and Tab 3.
If this ain't working like it should, then please
https://shagle.download
kindly check your Tab Stacking settings. It might be that the "Stacking Drop Delay"
https://voojio.com/chatroom/omegle
setting is too sensitive.
Denunciar
0
0
→ Voltar para WINDEV 26
WINDEV 26
Français
English
Español
Portuguesa
Fermer cette fenêtre
Tipo de Pesquisa
Apenas tópicos
Todas as mensagens
Período de pesquisa
Qualquer momento
Última hora
Últimas 24 horas
Semana passada
Mês passado
Ano passado
Cancelar
Pré-visualização da sua mensagem
Adicionar imagem
Importar uma imagem de uma URL
Enviar uma imagem a partir do seu disco
Deixe um ficheiro ou clique em "Procurar ..."
ou
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto