mkumaraguru49
asked on
Draw Line between two Listbox items (line may be one to many relationship)
I want to draw lines between two listbox items, the mapping relationship might be one-to-one, or one-to-many, or many-to-one relationship.
User want to do drag and drop listbox items and draw line between the items. I need sampe code uisng vb.net
User want to do drag and drop listbox items and draw line between the items. I need sampe code uisng vb.net
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I thought I had done that already....
I specifically wrote this small helper class to trap the scrolling messages:
Private Class ListBoxScroll
Inherits NativeWindow
Private Const WM_VSCROLL = &H115
Public Event Scrolled()
Public Sub New(ByVal lb As ListBox)
Me.AssignHandle(lb.Handle)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Messa ge)
If m.Msg = WM_VSCROLL Then
RaiseEvent Scrolled()
End If
MyBase.WndProc(m)
End Sub
End Class
and then I updated the lines whenever the ListBoxes were scrolled. If it's not working for you, please let me know what version VB.Net and version Windows you are working with.
I specifically wrote this small helper class to trap the scrolling messages:
Private Class ListBoxScroll
Inherits NativeWindow
Private Const WM_VSCROLL = &H115
Public Event Scrolled()
Public Sub New(ByVal lb As ListBox)
Me.AssignHandle(lb.Handle)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Messa
If m.Msg = WM_VSCROLL Then
RaiseEvent Scrolled()
End If
MyBase.WndProc(m)
End Sub
End Class
and then I updated the lines whenever the ListBoxes were scrolled. If it's not working for you, please let me know what version VB.Net and version Windows you are working with.
ASKER
Hi
I don't know that how to use this helper class. Could you please explain, how to use it, otherwise, give me a full sample code of this.
thank you
I don't know that how to use this helper class. Could you please explain, how to use it, otherwise, give me a full sample code of this.
thank you
The code in the link IS a FULL, WORKING example... =\
The helper class is being created in the Load() event of the Form:
Private WithEvents lbs1 As ListBoxScroll
Private WithEvents lbs2 As ListBoxScroll
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lbs1 = New ListBoxScroll(Me.ListBox1)
lbs2 = New ListBoxScroll(Me.ListBox2)
End Sub
Private Sub lbs1_Scrolled() Handles lbs1.Scrolled
Panel1.Refresh()
End Sub
Private Sub lbs2_Scrolled() Handles lbs2.Scrolled
Panel1.Refresh()
End Sub
The helper class is being created in the Load() event of the Form:
Private WithEvents lbs1 As ListBoxScroll
Private WithEvents lbs2 As ListBoxScroll
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lbs1 = New ListBoxScroll(Me.ListBox1)
lbs2 = New ListBoxScroll(Me.ListBox2)
End Sub
Private Sub lbs1_Scrolled() Handles lbs1.Scrolled
Panel1.Refresh()
End Sub
Private Sub lbs2_Scrolled() Handles lbs2.Scrolled
Panel1.Refresh()
End Sub
ASKER
It is really very helpful.
ASKER
The code is working fine. but i want to move the lines (drawn between 2 list box) when user scroll the list box...
what should i do ...
Thanks for yr support