FOROS PROFESIONALES
WINDEV
,
WEBDEV
y
WINDEV Mobile
Inicio
|
Mensajes recientes
|
Conéctese...
|
Desconectar
|
Español
Inicio
→
WINDEV 26
→
[WD25] drag-and-drop naar een TAB-control
[WD25] drag-and-drop naar een TAB-control
Iniciado por Stefan, 11,oct. 2021 15:52 - 2 respuestas
Conéctese…
Stefan
#1
Miembro registrado
7 mensajes
Publicado el 11,octubre 2021 - 15:52
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
Informar
0
0
SandraLewisFrin
#2
Miembro registrado
6 mensajes
Publicado el 11,marzo 2022 - 08:34
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;
}
}
}
Informar
0
0
SandraLewisFrin
#3
Miembro registrado
6 mensajes
Publicado el 05,abril 2022 - 12:10
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.
Informar
0
0
→ Volver a WINDEV 26
WINDEV 26
Français
English
Español
Portuguesa
Fermer cette fenêtre
Búsqueda Tipo
Sólo temas
Todos los mensajes
Periodo Buscar
Cualquier fecha
Última hora
Última 24 horas
Última semana
Último mes
Último año
Cancelar
Vista previa del mensaje
Añadiendo una imagen
Importar una imagen desde una URL
Enviar una imagen desde un archivo de su disco
Arrastrar un archivo o click en "Examinar..."
o
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto