Professional Web Applications Themes

System.Drawing and GDI+ Question - Please help - ASP.NET Building Controls

I have a winforms control that draws a rectangle for a boarder and positions some graphical elements around the control to create the boarder effect I desired. In the control I have overriden the onpaint event and added the code to draw my rectangle and position my graphic items: Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) e.Graphics.Clear(Color.FromArgb(255, 255, 255)) MyBase.OnPaint(e) Dim g As Graphics = pb1.CreateGraphics pb1.CreateGraphics.Clear(Color.FromArgb(255, 255, 255)) Dim myPen As System.Drawing.Pen = New System.Drawing.Pen(Color.FromArgb(187, 191, 115)) g.DrawRectangle(myPen, New Rectangle(0, 0, pb1.Width - 1, pb1.Height - 1)) pb1.Width = (Me.Width - 34) pb1.Height = (Me.Height - 29) tr.Left = ...

  1. #1

    Default System.Drawing and GDI+ Question - Please help

    I have a winforms control that draws a rectangle for a boarder and positions
    some graphical elements around the control to create the boarder effect I
    desired. In the control I have overriden the onpaint event and added the
    code to draw my rectangle and position my graphic items:

    Protected Overrides Sub OnPaint(ByVal e As
    System.Windows.Forms.PaintEventArgs)

    e.Graphics.Clear(Color.FromArgb(255, 255, 255))

    MyBase.OnPaint(e)

    Dim g As Graphics = pb1.CreateGraphics

    pb1.CreateGraphics.Clear(Color.FromArgb(255, 255, 255))

    Dim myPen As System.Drawing.Pen = New System.Drawing.Pen(Color.FromArgb(187,
    191, 115))

    g.DrawRectangle(myPen, New Rectangle(0, 0, pb1.Width - 1, pb1.Height - 1))

    pb1.Width = (Me.Width - 34)

    pb1.Height = (Me.Height - 29)

    tr.Left = (Me.Width - 32)

    br.Left = (Me.Width - 32)

    br.Top = (Me.Height - 24)

    bl.Top = (Me.Height - 24)

    End Sub

    Also I have added this line to the Public sub new call of the control:

    SetStyle(ControlStyles.ResizeRedraw, True)

    As you can see the rectangle is being drawn on a panel control called "pb1".

    When I drag this control onto a Windows form in Visual Studio the rectangle
    is drawn and behaves as it should when resized etc. However if I switch to
    antother tab and switch back the rectangle disapears, this is also the case
    when the solution is compiled the form initializes with no rectangle. Can
    somebody please help me or point me in the right direction.


    padawan Guest

  2. #2

    Default Re: System.Drawing and GDI+ Question - Please help

    I'm not sure if you noticed but you just posted a windows forms question in
    an asp.net news group ;P

    You will get proper help if you posted in the appropriate news group ;)

    "padawan" <pcthugnzparadise.net.nz> wrote in message
    news:uJtwzWz4DHA.2760TK2MSFTNGP09.phx.gbl...
    > I have a winforms control that draws a rectangle for a boarder and
    positions
    > some graphical elements around the control to create the boarder effect I
    > desired. In the control I have overriden the onpaint event and added the
    > code to draw my rectangle and position my graphic items:
    >
    > Protected Overrides Sub OnPaint(ByVal e As
    > System.Windows.Forms.PaintEventArgs)
    >
    > e.Graphics.Clear(Color.FromArgb(255, 255, 255))
    >
    > MyBase.OnPaint(e)
    >
    > Dim g As Graphics = pb1.CreateGraphics
    >
    > pb1.CreateGraphics.Clear(Color.FromArgb(255, 255, 255))
    >
    > Dim myPen As System.Drawing.Pen = New
    System.Drawing.Pen(Color.FromArgb(187,
    > 191, 115))
    >
    > g.DrawRectangle(myPen, New Rectangle(0, 0, pb1.Width - 1, pb1.Height - 1))
    >
    > pb1.Width = (Me.Width - 34)
    >
    > pb1.Height = (Me.Height - 29)
    >
    > tr.Left = (Me.Width - 32)
    >
    > br.Left = (Me.Width - 32)
    >
    > br.Top = (Me.Height - 24)
    >
    > bl.Top = (Me.Height - 24)
    >
    > End Sub
    >
    > Also I have added this line to the Public sub new call of the control:
    >
    > SetStyle(ControlStyles.ResizeRedraw, True)
    >
    > As you can see the rectangle is being drawn on a panel control called
    "pb1".
    >
    > When I drag this control onto a Windows form in Visual Studio the
    rectangle
    > is drawn and behaves as it should when resized etc. However if I switch to
    > antother tab and switch back the rectangle disapears, this is also the
    case
    > when the solution is compiled the form initializes with no rectangle. Can
    > somebody please help me or point me in the right direction.
    >
    >

    Alessandro Zifiglio Guest

  3. #3

    Default Re: System.Drawing and GDI+ Question - Please help

    Sorry, thanks.
    "Alessandro Zifiglio" <alessandrozifiglioNO-SPAM-hotmail.com> wrote in
    message news:PoOQb.7357$nC1.5313news.edisontel.com...
    > I'm not sure if you noticed but you just posted a windows forms question
    in
    > an asp.net news group ;P
    >
    > You will get proper help if you posted in the appropriate news group ;)
    >
    > "padawan" <pcthugnzparadise.net.nz> wrote in message
    > news:uJtwzWz4DHA.2760TK2MSFTNGP09.phx.gbl...
    > > I have a winforms control that draws a rectangle for a boarder and
    > positions
    > > some graphical elements around the control to create the boarder effect
    I
    > > desired. In the control I have overriden the onpaint event and added the
    > > code to draw my rectangle and position my graphic items:
    > >
    > > Protected Overrides Sub OnPaint(ByVal e As
    > > System.Windows.Forms.PaintEventArgs)
    > >
    > > e.Graphics.Clear(Color.FromArgb(255, 255, 255))
    > >
    > > MyBase.OnPaint(e)
    > >
    > > Dim g As Graphics = pb1.CreateGraphics
    > >
    > > pb1.CreateGraphics.Clear(Color.FromArgb(255, 255, 255))
    > >
    > > Dim myPen As System.Drawing.Pen = New
    > System.Drawing.Pen(Color.FromArgb(187,
    > > 191, 115))
    > >
    > > g.DrawRectangle(myPen, New Rectangle(0, 0, pb1.Width - 1, pb1.Height -
    1))
    > >
    > > pb1.Width = (Me.Width - 34)
    > >
    > > pb1.Height = (Me.Height - 29)
    > >
    > > tr.Left = (Me.Width - 32)
    > >
    > > br.Left = (Me.Width - 32)
    > >
    > > br.Top = (Me.Height - 24)
    > >
    > > bl.Top = (Me.Height - 24)
    > >
    > > End Sub
    > >
    > > Also I have added this line to the Public sub new call of the control:
    > >
    > > SetStyle(ControlStyles.ResizeRedraw, True)
    > >
    > > As you can see the rectangle is being drawn on a panel control called
    > "pb1".
    > >
    > > When I drag this control onto a Windows form in Visual Studio the
    > rectangle
    > > is drawn and behaves as it should when resized etc. However if I switch
    to
    > > antother tab and switch back the rectangle disapears, this is also the
    > case
    > > when the solution is compiled the form initializes with no rectangle.
    Can
    > > somebody please help me or point me in the right direction.
    > >
    > >
    >
    >

    padawan Guest

Similar Threads

  1. Out of Memory Exception: System.Drawing.Image.FromFile
    By anastasia in forum ASP.NET General
    Replies: 3
    Last Post: September 9th, 05:47 PM
  2. system.drawing ASP.NET VB Problem
    By RajDogLives in forum Dreamweaver AppDev
    Replies: 0
    Last Post: March 1st, 05:07 PM
  3. Question with Drawing Curves
    By Leonard Whee Chuen Lee in forum Macromedia Flash
    Replies: 1
    Last Post: September 16th, 04:41 PM
  4. problem system.drawing transparent web images
    By eruess in forum ASP.NET General
    Replies: 0
    Last Post: August 8th, 05:58 PM
  5. convert hex to System.Drawing.Color
    By Sreejumon[MVP] in forum ASP.NET General
    Replies: 1
    Last Post: June 27th, 12:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139