Drag and drop selected item from listbox into TeeChart

TeeChart for ActiveX, COM and ASP
Post Reply
NeoCodex
Newbie
Newbie
Posts: 7
Joined: Wed May 05, 2004 4:00 am
Location: Finland
Contact:

Drag and drop selected item from listbox into TeeChart

Post by NeoCodex » Thu Dec 02, 2004 2:37 pm

Hello!

Could someone provide me an example how to drag and drop one selected item from ListBox onto TeeChart.
It seems that TeeChart does not support OLEDragDrop method and OnDragDrop is triggered only if I drop the ListBox itself onto TeeChart. And that's not I want.

My need is drop only selected item's text onto TeeChart. How could this be done?

-Pekka-

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Dec 07, 2004 8:48 am

Hi Pekka!
Could someone provide me an example how to drag and drop one selected item from ListBox onto TeeChart.
Sure, you can try something similar to the following:

Code: Select all

Private Sub Form_Load()
With List1
    .AddItem "Banana"
    .AddItem "Kiwi"
    .AddItem "Orange"
End With
End Sub

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.Drag
End Sub

Private Sub TChart1_DragDrop(Source As Control, X As Single, Y As Single)
TChart1.AddSeries scLine
TChart1.Series(TChart1.SeriesCount - 1).FillSampleValues 10
TChart1.Series(TChart1.SeriesCount - 1).Title = Source
TChart1.Legend.LegendStyle = lsSeries
End Sub

Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
   ' Change pointer to no drop.
   If State = 0 Then Source.MousePointer = 12
   ' Use default mouse pointer.
   If State = 1 Then Source.MousePointer = 0
End Sub
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

NeoCodex
Newbie
Newbie
Posts: 7
Joined: Wed May 05, 2004 4:00 am
Location: Finland
Contact:

It works but...

Post by NeoCodex » Tue Dec 07, 2004 12:42 pm

Thanks for the example.

It does exactly what I want but there's one "cosmetical" issue:
When I start to drag selected item a gray frame of the listbox seems to be dragged not selected item.
It does not look good if I want visualize one item to be dragged from the listbox into TeeChart.

Is it possible to change mouse cursor when dragging is started and hide the drag frame of the listbox?

-Pekka-

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Dec 09, 2004 11:39 am

Hi Pekka,

I'm afraid not, this seems to be the Visual Basic behaviour.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

NeoCodex
Newbie
Newbie
Posts: 7
Joined: Wed May 05, 2004 4:00 am
Location: Finland
Contact:

Post by NeoCodex » Fri Dec 10, 2004 1:02 pm

narcis wrote:Hi Pekka,

I'm afraid not, this seems to be the Visual Basic behaviour.
Hmm... I've seen OLEDragDrop method used with VB components also in listbox. If that method is used you can drag and drop each item of the list. Unfortunately TeeChart has no such method. Why?

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Dec 10, 2004 4:45 pm

Hi,

this feature is not implemented in the TeeChart Pro ActiveX. I've added it on our wish list to be considered for the next releases.

NeoCodex
Newbie
Newbie
Posts: 7
Joined: Wed May 05, 2004 4:00 am
Location: Finland
Contact:

Post by NeoCodex » Mon Dec 13, 2004 7:22 am

Hello again.

It's ok to me to use plain DragDrop method. But still I want nice and clean visualizing of one item drag from listbox into teechart. It's soo ugly to drag and drop gray frame of the listbox...

Does anyone know a trick/workaround/something to hide drag frame from listbox and change mouse cursor to visualize item dragging?

-Pekka-

NeoCodex
Newbie
Newbie
Posts: 7
Joined: Wed May 05, 2004 4:00 am
Location: Finland
Contact:

Post by NeoCodex » Mon Dec 13, 2004 1:53 pm

9082336 wrote:Hello again.

It's ok to me to use plain DragDrop method. But still I want nice and clean visualizing of one item drag from listbox into teechart. It's soo ugly to drag and drop gray frame of the listbox...

Does anyone know a trick/workaround/something to hide drag frame from listbox and change mouse cursor to visualize item dragging?

-Pekka-
AAAAA ! I got it! It seems that when object's DragIcon is not defined a gray frame is displayed when dragging the object. When I defined an icon for object's DragIcon property no drag frame was displayed and mouse cursor was changed to icon I wanted.

So case is now closed.
Thanx for your support guys!

-Pekka-

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Dec 14, 2004 7:01 am

Hi Pekka,

thanks for the tip, I was not aware of this.

NeoCodex
Newbie
Newbie
Posts: 7
Joined: Wed May 05, 2004 4:00 am
Location: Finland
Contact:

Post by NeoCodex » Wed Dec 15, 2004 10:58 am

Hmm... one thing more:

How about drag'n drop between two forms?

Scenario: I have item list in FormA and TeeChart in FormB.
I want drag items from FormA's item list into FormB's TeeChart.

How that can be done?

-Pekka-

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Dec 20, 2004 10:08 am

Hi Pekka,

usign the same code for the formB should work fine :
Code FormA

Code: Select all

Private Sub Form_Load()
With List1
    .AddItem "Banana"
    .AddItem "Kiwi"
    .AddItem "Orange"
End With
Form2.Show
End Sub

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.Drag
End Sub

Private Sub TChart1_DragDrop(Source As Control, X As Single, Y As Single)
TChart1.AddSeries scLine
TChart1.Series(TChart1.SeriesCount - 1).FillSampleValues 10
TChart1.Series(TChart1.SeriesCount - 1).Title = Source
TChart1.Legend.LegendStyle = lsSeries
End Sub

Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
   ' Change pointer to no drop.
   If State = 0 Then Source.MousePointer = 12
   ' Use default mouse pointer.
   If State = 1 Then Source.MousePointer = 0
End Sub
Code FormB

Code: Select all

Private Sub Form_Load()
With List1
    .AddItem "Banana"
    .AddItem "Kiwi"
    .AddItem "Orange"
End With
End Sub

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.Drag
End Sub

Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
   ' Change pointer to no drop.
   If State = 0 Then Source.MousePointer = 12
   ' Use default mouse pointer.
   If State = 1 Then Source.MousePointer = 0
End Sub

Post Reply