FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 26
→
[WD25] drag-and-drop naar een TAB-control
[WD25] drag-and-drop naar een TAB-control
Débuté par Stefan, 11 oct. 2021 15:52 - 2 réponses
Connectez-vous…
Stefan
#1
Membre enregistré
7 messages
Posté le 11 octobre 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
Signaler
0
0
SandraLewisFrin
#2
Membre enregistré
6 messages
Posté le 11 mars 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;
}
}
}
Signaler
0
0
SandraLewisFrin
#3
Membre enregistré
6 messages
Posté le 05 avril 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.
Signaler
0
0
→ Revenir à WINDEV 26
WINDEV 26
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte