473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

drawing a rectangle in a form

I try to draw a rectangle in a form on a buttons click event, The code is
Dim bitmap As New Bitmap("lysblaa.jpg")

Dim tBrush As New TextureBrush(bitmap)

Dim texturedPen As New Pen(tBrush, 30)

e.Graphics.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height)

e.Graphics.DrawEllipse(texturedPen, 100, 20, 200, 100)

I get an error on e.Graphics...

I have trie to set Imports System.Drawing.Design but it doesn't help

reidarT
Sep 6 '06 #1
3 1337
"reidarT" <re****@eivon.noschrieb:
>I try to draw a rectangle in a form on a buttons click event, The code is
Dim bitmap As New Bitmap("lysblaa.jpg")

Dim tBrush As New TextureBrush(bitmap)

Dim texturedPen As New Pen(tBrush, 30)

e.Graphics.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height)

e.Graphics.DrawEllipse(texturedPen, 100, 20, 200, 100)

I get an error on e.Graphics...

I have trie to set Imports System.Drawing.Design but it doesn't help

\\\
Private m_Button1Clicked As Boolean

Private Sub Button1_Click(...) Handles Button1.Click
m_Button1Clicked = True
Me.Invalidate(...)
End Sub

Private Sub Form_Paint(...) Handles MyBase.Paint
If m_Button1Clicked Then
...
e.Graphics.DrawImage(...)
...
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Sep 6 '06 #2
I have tried to do like you suggested with this code

Private m_Button1Clicked As Boolean

Private Sub Button1_Click() Handles Button1.Click

m_Button1Clicked = True

Me.Invalidate()

End Sub

Private Sub Form_Paint() Handles MyBase.Paint

If m_Button1Clicked Then

e.Graphics.DrawImage("1.jpg")

End If

End Sub

but I get n error on Button1.click and e.graphics

reidarT
"Herfried K. Wagner [MVP]" <hi***************@gmx.atskrev i melding
news:ek**************@TK2MSFTNGP03.phx.gbl...
"reidarT" <re****@eivon.noschrieb:
>>I try to draw a rectangle in a form on a buttons click event, The code is
Dim bitmap As New Bitmap("lysblaa.jpg")

Dim tBrush As New TextureBrush(bitmap)

Dim texturedPen As New Pen(tBrush, 30)

e.Graphics.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height)

e.Graphics.DrawEllipse(texturedPen, 100, 20, 200, 100)

I get an error on e.Graphics...

I have trie to set Imports System.Drawing.Design but it doesn't help


\\\
Private m_Button1Clicked As Boolean

Private Sub Button1_Click(...) Handles Button1.Click
m_Button1Clicked = True
Me.Invalidate(...)
End Sub

Private Sub Form_Paint(...) Handles MyBase.Paint
If m_Button1Clicked Then
...
e.Graphics.DrawImage(...)
...
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Sep 7 '06 #3
"reidarT" <re****@eivon.noschrieb:
Private Sub Button1_Click() Handles Button1.Click
[...]
Private Sub Form_Paint() Handles MyBase.Paint
The methods's signatures are wrong. I didn't include the complete parameter
list because I didn't test the code in the IDE. Instead I just used
ellipsis instead to simplify typing the post. I suggest to create handlers
for the button's 'Click' event and the form's 'Paint' event using the IDE by
selecing the object in the left dropdown list on top of the code editor and
then selecting the event in the combobox on the right hand side.
e.Graphics.DrawImage("1.jpg")
\\\
Private m_Image As Image = Image.FromFile("1.jpg")
....
Private Sub Form_Paint(...) Handles MyBase.Paint
e.Graphics.DrawImage(m_Image)
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Sep 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: padawan | last post by:
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...
1
by: Yuelin | last post by:
Hi, thanks for the answers to my previous questions. Now I have a question on drawing in C#: For example I have written following code to draw a rectangle on a form: protected override void...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
4
by: Colin McGuire | last post by:
Hi, this is a really simple question I have been banging my head on a brick wall over. The program below changes the background colour of a form depending on whether the cursor is inside a...
1
by: YYZ | last post by:
Sorry for the multipost, but no one was responding in the other thread. If any solution is forthcoming, I will return to the original thread and post it there as well. I've created a usercontrol...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
1
by: lab3terch | last post by:
Imports System.Drawing.Graphics Public Class Form1 Inherits System.Windows.Forms.Form Dim x1, y1, x2, y2 As Integer Dim red, black, blue, green, orange As Color Dim x, y, w, h...
7
by: ddecoste | last post by:
I have a need to add a visual representation to some data in Access. I need to draw a matix of squares inside another square. I have all the data that I need in a record in Access. The data...
12
by: Petra Rohmer | last post by:
Hello, I want to ake following 0,0 (900mm,900mm) -------------------------------------- |....................................| |....................................|...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.