Re: Drawing in a user control

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks Bob and Lloyd; Finally I am using this:


Public Class usrChart
Private DrawingArea As Bitmap


Private Sub usrChart_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
Me.Height = ChartHeight
Me.Width = ChartWidth
DrawingArea = New Bitmap(Me.ClientRectangle.Width,
Me.ClientRectangle.Height,
System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub

Private Sub usrChart_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Try

Dim oGraphics As Graphics
oGraphics = e.Graphics
oGraphics.DrawImage(DrawingArea, 0, 0, DrawingArea.Width,
DrawingArea.Height)

Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub

Public Sub ShowBandModel(ByRef iCurveNo As Integer, ByRef bolShadow
As Boolean)
Try

Dim iX As Single = 0
Dim iY As Single = 0
Dim oPen As Pen
Dim e1 As Graphics = Graphics.FromImage(DrawingArea)
..............
e1.Dispose()
Me.Invalidate()
End Sub


End Class

And it's working well..... I think....


Bob, what are the differences between use Control or User Control as
base class? and what did you say "Ah, also NEVER create a control that
handles it's own events"?



Thanks,
Fernando.

.



Relevant Pages

  • Re: how do i play wav over tapi3 (vb.net)
    ... Regarding TAPI and .NET see KB article ... Public Sub New ... Private Sub InitializeComponent() ... Dim WithEvents gObjTapiWithEvents As TAPI ...
    (microsoft.public.win32.programmer.tapi)
  • Re: DropDownList SelectedIndex problem in C# (from working VB.NET)
    ... > Private Sub Page_Load(ByVal sender As System.Object, ... > Sub BindData() ... > Dim objConn As New SqlConnection ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: Filewatch saga continues
    ... Public Sub NKWatch_Created(ByVal sender As Object, ... Dim frmFirst As New Form1 ...
    (microsoft.public.dotnet.general)
  • Draw lines and icons on a form?
    ... I want to draw on the picturebox some vertical lines and some icons ... Private Sub DrawArea ... Dim XStart As Long, xEnd As Long ... Then Exit Sub ...
    (microsoft.public.vb.general.discussion)
  • Re: Email address from AD
    ... Private Sub InitializeComponent() ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim txtSam As String ... Dim cResult As SearchResultCollection ...
    (microsoft.public.dotnet.languages.vb)