Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - How to drag records to TreeView-control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to drag records to TreeView-control

 Post Reply Post Reply
Author
Message
CapoPezzio View Drop Down
Groupie
Groupie


Joined: 13 April 2010
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote CapoPezzio Quote  Post ReplyReply Direct Link To This Post Topic: How to drag records to TreeView-control
    Posted: 30 September 2010 at 2:38pm
I wonder if anyone can show me how to drag and drop records from a ReportControl to a node in a TreeView-control(Codejocks Treeviewcontrol. Small example would be nice. Thank you
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 (32bit)
Language: Visual Basic 6.0
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 30 September 2010 at 5:02pm
Here's a basic example (you should check whether or not the dropped data is from a ReportControl in your production code).


Option Explicit

Private m_ClipboardFormat As Long

Private Sub Form_Load()
   With Me.TreeView1
      ' Enable OLE drop mode for the Treeview
      .OLEDropMode = xtpOLEDropManual
   End With
  
   With Me.ReportControl1
      .Columns.Add 0, "", 100, True
     
      ' Add some dummy records
      With .Records.Add
         .AddItem "a"
      End With
      With .Records.Add
         .AddItem "b"
      End With
      With .Records.Add
         .AddItem "c"
      End With
      With .Records.Add
         .AddItem "d"
      End With
      With .Records.Add
         .AddItem "e"
      End With
      With .Records.Add
         .AddItem "f"
      End With
     
      ' Register the report control clipboard/dragdrop format.
      ' We will use the return value to get data out of the drag & drop data object
      m_ClipboardFormat = .EnableDragDrop("ABC", xtpReportAllowDragCopy)
     
      .Populate
     
   End With
End Sub

Private Sub TreeView1_OLEDragDrop(ByVal Data As XtremeSuiteControls.DataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
   Dim lo_Records As XtremeReportControl.ReportRecords
   Dim i As Long
  
   ' Create a ReportRecords collection from the dropped data
   Set lo_Records = Me.ReportControl1.CreateRecordsFromDropArray(Data.GetData(m_ClipboardFormat))
  
   ' Add the items in the ReportRecords collection to the TreeView
   For i = 1 To lo_Records.Count
      Me.TreeView1.Nodes.Add , , , lo_Records.Record(i - 1).Item(0).Value
   Next i
End Sub


Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
CapoPezzio View Drop Down
Groupie
Groupie


Joined: 13 April 2010
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote CapoPezzio Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2010 at 1:59am
Thank you jpbro. Do you know how I can find wich node(the index) in the tree the records are dropped to, so I can add my records under that node
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 (32bit)
Language: Visual Basic 6.0
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2010 at 3:22pm
You can use the HitTest method of the TreeView control to determine the node that the mouse is over when the drop operation occurs. So:


Option Explicit

Private m_ClipboardFormat As Long

Private Sub Form_Load()
   With Me.TreeView1
      ' Enable OLE drop mode for the Treeview
      .OLEDropMode = xtpOLEDropManual  ' BUG: TreeView won't fire OLE* events when this value is set in code
                                       '      - only works when set in the VB6 Property Browser
     
      .ShowLines = xtpTreeViewShowLinesAtRoot
      .ShowPlusMinus = True
   End With
  
   With Me.ReportControl1
      .Columns.Add 0, "", 100, True
     
      ' Add some dummy records
      With .Records.Add
         .AddItem "a"
      End With
      With .Records.Add
         .AddItem "b"
      End With
      With .Records.Add
         .AddItem "c"
      End With
      With .Records.Add
         .AddItem "d"
      End With
      With .Records.Add
         .AddItem "e"
      End With
      With .Records.Add
         .AddItem "f"
      End With
     
      ' Register the report control clipboard/dragdrop format.
      ' We will use the return value to get data out of the drag & drop data object
      m_ClipboardFormat = .EnableDragDrop("ABC", xtpReportAllowDragCopy)
     
      .Populate
     
   End With
End Sub

Private Sub TreeView1_OLEDragDrop(ByVal Data As XtremeSuiteControls.DataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
   Dim lo_Records As XtremeReportControl.ReportRecords
   Dim i As Long
  
   Dim lo_Node As TreeViewNode
  
   ' Determine if we dropped the reportcontrol records onto a treeview node
   Set lo_Node = Me.TreeView1.HitTest(x, y)
  
   ' Create a ReportRecords collection from the dropped data
   Set lo_Records = Me.ReportControl1.CreateRecordsFromDropArray(Data.GetData(m_ClipboardFormat))
  
   ' Add the items in the ReportRecords collection to the TreeView
   For i = 1 To lo_Records.Count
      Me.TreeView1.Nodes.Add IIf(lo_Node Is Nothing, Empty, lo_Node), IIf(lo_Node Is Nothing, Empty, xtpTreeViewChild), , lo_Records.Record(i - 1).Item(0).Value
   Next i
  
  
   ' BUG: TreeView doesn't update +/- button after OLE Drag & Drop,
   ' so hide & show the control to force redraw as a hack/workaround
   With Me.TreeView1
      .Visible = False
      .Visible = True
   End With
End Sub



Interestingly, your posts have turned up 2 apparent bugs in the TreeView control:

1) You can't set the OleDropMode property in code only, you must set it in the VB6 property browser.
2) The Treeview doesn't update the +/- icon after you add items in the OleDragDrop event, so you have to hide/show the control as a hack/workaround to refresh it.

CAN ANYONE CONFIRM THESE BUGS IN 13.4.1? I haven't installed it yet, but I'd like to know if they are still bugs before I open tickets.

Thanks.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2010 at 2:27am
Originally posted by jpbro jpbro wrote:

 
[...]
Interestingly, your posts have turned up 2 apparent bugs in the TreeView control:

1) You can't set the OleDropMode property in code only, you must set it in the VB6 property browser.
2) The Treeview doesn't update the +/- icon after you add items in the OleDragDrop event, so you have to hide/show the control as a hack/workaround to refresh it.

CAN ANYONE CONFIRM THESE BUGS IN 13.4.1? I haven't installed it yet, but I'd like to know if they are still bugs before I open tickets.

Thanks.
 
Hi Jason,
 
I tried with V13.4.1 and problem 1 seems to be solved so I guess you have to open one ticket Wink
(for plus/minus issue)
 
btw Jason, I'm not able to copy/paste your code in "normal way". I have to click QUOTE and copy/paste your code (between the [code] section) Only this way it will be pasted right way. Is there another way to get the code? Thanks in advance. 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2010 at 9:37am
Hi Aaron, thanks for testing it out, I'll open a ticket.

I don't know why you can't copy & paste my code - I've just put it between {code}{/code} tags (with square brackets, not braces), and I am able to copy & paste it fine. How do you post your code snippets?
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2010 at 11:43am
Originally posted by jpbro jpbro wrote:

Hi Aaron, thanks for testing it out, I'll open a ticket.

I don't know why you can't copy & paste my code - I've just put it between {code}{/code} tags (with square brackets, not braces), and I am able to copy & paste it fine. How do you post your code snippets?
 
Hi,
 
I just type code in message as text (if code is too long, most of the time I upload test project)
 

'Test copy/paste (I put the code in brackets as well)
With Me.wndReportControl
        With .PaintManager
            .ColumnStyle = xtpColumnOffice2007
            .FormulaSumColor = vbRed
        End With
End With
 
So if I copy above from forum I get this:
 
'Test copy/paste (I put the code in brackets as well)
With Me.wndReportControl        With .PaintManager            .ColumnStyle = xtpColumnOffice2007            .FormulaSumColor = vbRed        End With
End With 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2010 at 9:14pm
Ah, I see it is a problem with Internet Explorer - I use Firefox, and it works fine for copying and pasting text from within the code tags. I don't know if it's a forum bug or an IE bug.

I'll try to upload test projects, it's just a bit more time consuming...




Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
CapoPezzio View Drop Down
Groupie
Groupie


Joined: 13 April 2010
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote CapoPezzio Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 9:26am
Thanks a lot you guys. I now manage to drag and drop records from the reportcontrol to the treeview. But I have a new drag and drop-problem with the TreeView-control(This should maybe be in the Controls section). I cant manage do drag and drop nodes within the TreeView-control. Drag Reportcontrol-records to a treeview-node works fine, but I cant drag and drop a treeview-node to another treeview-node., I dont get any events. I dont get to show the PlusMinus-sign on the Treeviewcontrol-nodes when I have icons on the nodes either. Someone help please?
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 (32bit)
Language: Visual Basic 6.0
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.