4 Replies - 2258 Views - Last Post: 16 February 2011 - 02:49 PM Rate Topic: -----

#1 smrl74x10  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-December 10

'Graphics' not part of System.eventargs

Posted 15 February 2011 - 04:07 PM

I am researching ways to use vbTab and Tab stops to create
a report in VB 10. I found some code that demostates the
tab methods. When I plug the code into Visual Studio 10,
I get 'graphics' not part of System.eventsargs, referring
to the g.graphics.drawstring command. How do I solve this
problem? I have tried several different imports statements
with no success. Thanks Bob
Is This A Good Question/Topic? 0
  • +

Replies To: 'Graphics' not part of System.eventargs

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,087
  • Joined: 02-July 08

Re: 'Graphics' not part of System.eventargs

Posted 15 February 2011 - 05:24 PM

What event is that code in? Show us some more code.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Bob Smith*


Reputation:

Re: 'Graphics' not part of System.eventargs

Posted 16 February 2011 - 11:15 AM

Here is the code:
Imports System.Drawing.Graphics
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        Dim myText As String = _
                   "Name" & ControlChars.Tab & _
                   "Test 1" & ControlChars.Tab & _
                   "Test 2" & ControlChars.Tab & _
                   "Test 3" & ControlChars.Cr

        myText = myText & "Joe" & ControlChars.Tab & _
                          "95" & ControlChars.Tab & _
                          "88" & ControlChars.Tab & _
                          "91" & ControlChars.Cr
        myText = myText & "Mary" & ControlChars.Tab & _
                          "98" & ControlChars.Tab & _
                          "84" & ControlChars.Tab & _
                          "90" & ControlChars.Cr
        myText = myText & "Sam" & ControlChars.Tab & _
                          "42" & ControlChars.Tab & _
                          "76" & ControlChars.Tab & _
                          "98" & ControlChars.Cr
        myText = myText & "Jane" & ControlChars.Tab & _
                          "65" & ControlChars.Tab & _
                          "73" & ControlChars.Tab & _
                          "92" & ControlChars.Cr

        Dim fontFamily As New FontFamily("Courier New")
        Dim font As New Font( _
           fontFamily, _
           12, _
           FontStyle.Regular, _
           GraphicsUnit.Point)
        Dim rect As New Rectangle(10, 10, 450, 100)
        Dim stringFormat As New StringFormat()
        Dim solidBrush As New SolidBrush(Color.FromArgb(255, 0, 0, 255))
        Dim tabs As Single() = {150, 100, 100, 100}

        stringFormat.SetTabStops(0, tabs)

        e.Graphics.DrawString(myText, font, solidBrush, RectangleF.op_Implicit(rect), stringFormat)

        Dim pen As Pen = Pens.Black
        e.Graphics.DrawRectangle(pen, rect)




    End Sub
End Class

This post has been edited by AdamSpeight2008: 16 February 2011 - 11:45 AM
Reason for edit:: Please use the CodeTags

Was This Post Helpful? 1

#4 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: 'Graphics' not part of System.eventargs

Posted 16 February 2011 - 11:34 AM

Hi,

e, that you are refering to is an EventArg and does not handle any graphics.

The Forms/button/picturebox etc. their Paint() method handles graphics and there you could use "e.graphics".

You can also do Button1.CreateGraphics or Form1.CreateGraphics ... (what you were trying to do is paint on the "click event" itself and that is not supported. you can paint something on something else with the click event yes, but not on the click event itself.. it would be like painting the paint action and not a wall.)
Was This Post Helpful? 1
  • +
  • -

#5 smrl74x10  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-December 10

Re: 'Graphics' not part of System.eventargs

Posted 16 February 2011 - 02:49 PM

I moved the code under a print page event and it works fine. Thank You Bob
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1