Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.net erase line between two points

Posted on 2012-04-03
3
Medium Priority
?
427 Views
Last Modified: 2012-04-03
Hi. I use the following code to draw a line between two points on a TreeView. What code would I use to clear this line

    Sub oDrawLine()

        Dim Gr As Graphics = Me.TreeView_From.CreateGraphics()
        ' Create pen.
        Dim blackPen As New Pen(Color.DarkOrange, 2)

        ' Draw line to screen.
        Gr.DrawLine(blackPen, oFrom_Point, oTo_Point)

    End Sub
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 37801434
You've used CreateGraphics(), which is a temporary drawing surface.  To erase, just Refresh() the Form/TreeView.  If you are not calling that method from the Paint() event then it will be erased for you.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 total points
ID: 37801550
Strange variable name, blackPen, for an orange line, even it is is dark orange :-)

If the line never cross anything else, simply create a DeleteLine method with the same code, but use the TreeView BackColor instead of the DarkOrange.
0
 

Author Closing Comment

by:Murray Brown
ID: 37801939
thanks very much
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

661 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