Page 1 of 1
Drag and drop selected item from listbox into TeeChart
Posted: Thu Dec 02, 2004 2:37 pm
by 9082336
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-
Posted: Tue Dec 07, 2004 8:48 am
by Chris
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
It works but...
Posted: Tue Dec 07, 2004 12:42 pm
by 9082336
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-
Posted: Thu Dec 09, 2004 11:39 am
by narcis
Hi Pekka,
I'm afraid not, this seems to be the Visual Basic behaviour.
Posted: Fri Dec 10, 2004 1:02 pm
by 9082336
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?
Posted: Fri Dec 10, 2004 4:45 pm
by Pep
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.
Posted: Mon Dec 13, 2004 7:22 am
by 9082336
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-
Posted: Mon Dec 13, 2004 1:53 pm
by 9082336
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-
Posted: Tue Dec 14, 2004 7:01 am
by Pep
Hi Pekka,
thanks for the tip, I was not aware of this.
Posted: Wed Dec 15, 2004 10:58 am
by 9082336
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-
Posted: Mon Dec 20, 2004 10:08 am
by Pep
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