Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Draw Line between two Listbox items (line may be one to many relationship)

Posted on 2009-02-22
6
Medium Priority
?
1,341 Views
Last Modified: 2012-05-06
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


0
Comment
Question by:mkumaraguru49
  • 3
  • 3
6 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1500 total points
ID: 23706527
0
 

Author Comment

by:mkumaraguru49
ID: 23743190
Hi
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
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23745413
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.Message)
            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.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:mkumaraguru49
ID: 23752017
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
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23752213
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
0
 

Author Comment

by:mkumaraguru49
ID: 23823815
It is really very helpful.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question