Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to Draw a Line ???

How to Draw a Line ???

Scheduled Pinned Locked Moved Visual Basic
graphicstutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 765502
    wrote on last edited by
    #1

    hi every one,i would like to draw a single line in my form,for that i am using the following code which i got from the samle code,but i just dont know what wrong with my code as i not geting the line, Dim g As Graphics 'Sets g to a Graphics object representing the drawing surface of the ' control or form g is a member of. 'g = BtnLogin.CreateGraphics g = Me.CreateGraphics Dim myPen As New Pen(Color.White) myPen.DashStyle = Drawing.Drawing2D.DashStyle.Dash myPen.Width = 2 g.DrawLine(myPen, 4, 2, 12, 6) pls get back to me.after viewing this

    D P 2 Replies Last reply
    0
    • U User 765502

      hi every one,i would like to draw a single line in my form,for that i am using the following code which i got from the samle code,but i just dont know what wrong with my code as i not geting the line, Dim g As Graphics 'Sets g to a Graphics object representing the drawing surface of the ' control or form g is a member of. 'g = BtnLogin.CreateGraphics g = Me.CreateGraphics Dim myPen As New Pen(Color.White) myPen.DashStyle = Drawing.Drawing2D.DashStyle.Dash myPen.Width = 2 g.DrawLine(myPen, 4, 2, 12, 6) pls get back to me.after viewing this

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Where in your app is this code? Is it in the OnPaint Event of your form? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      • U User 765502

        hi every one,i would like to draw a single line in my form,for that i am using the following code which i got from the samle code,but i just dont know what wrong with my code as i not geting the line, Dim g As Graphics 'Sets g to a Graphics object representing the drawing surface of the ' control or form g is a member of. 'g = BtnLogin.CreateGraphics g = Me.CreateGraphics Dim myPen As New Pen(Color.White) myPen.DashStyle = Drawing.Drawing2D.DashStyle.Dash myPen.Width = 2 g.DrawLine(myPen, 4, 2, 12, 6) pls get back to me.after viewing this

        P Offline
        P Offline
        progload
        wrote on last edited by
        #3

        Here's a user control that draws a 3D line like vb 6 has built-in. '------------------------------------- Imports System.Drawing Public Class ThreeDLine Inherits System.Windows.Forms.UserControl #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'UserControl overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Private Sub InitializeComponent() ' 'ThreeDLine ' Me.Name = "ThreeDLine" Me.Size = New System.Drawing.Size(472, 152) End Sub #End Region Public Enum tOrientation Horizontal Vertical End Enum Public Property Orientation() As tOrientation Get Return m_Orientation End Get Set(ByVal Value As tOrientation) m_Orientation = Value 'Set a "default" height and width If m_Orientation = tOrientation.Horizontal Then Me.Width = 120 Me.Height = 2 Else Me.Width = 2 Me.Height = 100 End If End Set End Property Private m_Orientation As tOrientation Private Sub ThreeDLine_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint 'Draws the line 'Point Variables Dim pL1 As Point Dim pL2 As Point Dim pL3 As Point Dim pL4 As Point 'Create a pen, you can change the colours if they're wrong. Dim DP As New Pen(System.Drawing.SystemColors.ControlDark) Dim LP As New Pen(SystemColors.ControlLight) 'Determine orientation then set the height of the control 'Set the sta

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups