473,782 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(bi tmap)

Dim texturedPen As New Pen(tBrush, 30)

e.Graphics.Draw Image(bitmap, 0, 0, bitmap.Width, bitmap.Height)

e.Graphics.Draw Ellipse(texture dPen, 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 1354
"reidarT" <re****@eivon.n oschrieb:
>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(bi tmap)

Dim texturedPen As New Pen(tBrush, 30)

e.Graphics.Draw Image(bitmap, 0, 0, bitmap.Width, bitmap.Height)

e.Graphics.Draw Ellipse(texture dPen, 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_Button1Clicke d As Boolean

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

Private Sub Form_Paint(...) Handles MyBase.Paint
If m_Button1Clicke d Then
...
e.Graphics.Draw Image(...)
...
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_Button1Clicke d As Boolean

Private Sub Button1_Click() Handles Button1.Click

m_Button1Clicke d = True

Me.Invalidate()

End Sub

Private Sub Form_Paint() Handles MyBase.Paint

If m_Button1Clicke d Then

e.Graphics.Draw Image("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******** ******@TK2MSFTN GP03.phx.gbl...
"reidarT" <re****@eivon.n oschrieb:
>>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(bi tmap)

Dim texturedPen As New Pen(tBrush, 30)

e.Graphics.Dra wImage(bitmap, 0, 0, bitmap.Width, bitmap.Height)

e.Graphics.Dra wEllipse(textur edPen, 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_Button1Clicke d As Boolean

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

Private Sub Form_Paint(...) Handles MyBase.Paint
If m_Button1Clicke d Then
...
e.Graphics.Draw Image(...)
...
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.n oschrieb:
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.Draw Image("1.jpg")
\\\
Private m_Image As Image = Image.FromFile( "1.jpg")
....
Private Sub Form_Paint(...) Handles MyBase.Paint
e.Graphics.Draw Image(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
1649
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 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))
1
4562
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 OnPaint ( PaintEventArgs e) { Graphics dc = e.Graphics; Pen BluePen = new Pen(Volor.Blue, 3);
13
3348
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 referenced, custom dll. I call a PrintImage routine in the dll and pass it only the the Picturebox.hdc from the main form. The dll's print routine draws to the hdc and it shows up in the picturebox perfectly. I would like to do a similar thing...
4
2673
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 rectangle drawn on the form or not. It works perfectly as shown below. But it won't work if I change the values of scaleFactor, rotateFactor, translateFactorX, translateFactorY in the program. I would like to 'correct' the values of e.X and e.Y in...
1
1714
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 and I'm trying to emulate the look of a mac effect (just for showing some options to my boss) by using 2 gradient rectangles. I'm having a LOT of trouble doing this, however, because I keep getting a 1 or 2 pixel line showing up. Can someone...
9
3181
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 want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
1
1775
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 As Integer Dim rectangle, freehand As Graphics Dim line As Graphics Dim wide, n As Integer
7
7078
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 changes according to what the user inputs. I know that Access does not allow you to draw on forms so I decided to put the output in an Excel file for the user but I am having trouble drawing the rectange from Access. Here is my simple code so far: ...
12
18353
by: Petra Rohmer | last post by:
Hello, I want to ake following 0,0 (900mm,900mm) -------------------------------------- |....................................| |....................................| |....................................|
7
3561
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 excellent transforms specified on Bob Powell's site, I still wonder if there's an easier way of centering it than the following procedure? Here is what I do now (it's awkward but it works): 1) I follow the transforms specified on Bob Powell's...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.