473,406 Members | 2,849 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,406 software developers and data experts.

put pixel

How to put pixel or draw line in VB.NET?

Please short example.

B.
Nov 20 '05 #1
6 2175
On which control you want to paint?

Following code will draw a line on a form, by hooking up to the paint event:
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint
Dim g As Graphics = e.Graphics()
Dim pen As New Pen(Color.Black)
pen.Width = 3
g.DrawLine(pen, 1, 10, Me.Width, 10)
End Sub
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Bulba008" <bu******@op.pl> schreef in bericht
news:bq**********@news.onet.pl...
How to put pixel or draw line in VB.NET?

Please short example.

B.

Nov 20 '05 #2
* "Jan Tielens" <ja*@no.spam.please.leadit.be> scripsit:
Following code will draw a line on a form, by hooking up to the paint event:
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint
Dim g As Graphics = e.Graphics()
Dim pen As New Pen(Color.Black)
pen.Width = 3
g.DrawLine(pen, 1, 10, Me.Width, 10)
\\\
p.Dispose()
///
End Sub


--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Herfried,
Did you mean:

pen.Dispose()

As there are no p variables in Jan's example.

You don't want to dispose the Graphics variables as this is the Paint event.

Hope this helps
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ee**************@TK2MSFTNGP10.phx.gbl...
* "Jan Tielens" <ja*@no.spam.please.leadit.be> scripsit:
Following code will draw a line on a form, by hooking up to the paint event: Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint
Dim g As Graphics = e.Graphics()
Dim pen As New Pen(Color.Black)
pen.Width = 3
g.DrawLine(pen, 1, 10, Me.Width, 10)


\\\
p.Dispose()
///
End Sub


--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit:
Did you mean:

pen.Dispose()

As there are no p variables in Jan's example.
Yes, sorry.
You don't want to dispose the Graphics variables as this is the Paint event.


ACK.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
Thx guys!

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:eQ**************@TK2MSFTNGP12.phx.gbl...
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit:
Did you mean:

pen.Dispose()

As there are no p variables in Jan's example.
Yes, sorry.
You don't want to dispose the Graphics variables as this is the Paint

event.
ACK.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #6
thanks
Nov 20 '05 #7

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

Similar topics

4
by: grogerteal | last post by:
Hello, I am pretty new to programming and would like someone to help me get started on the program that I need to make. I hope it is not hard to do, but what I would like is a simple app that...
10
by: unknown | last post by:
some one can give me a portable source codes that color a pixel? (env *nix) -- unknown
7
by: TomHL | last post by:
hello, - I have a Bitmap Object named: bmp1 - I already have the numerical values of:red,blue and green colors + I have the X and Y cordinates. How do I set the pixel value via safe code on...
7
by: walter.alex | last post by:
November 16 2005 -- The recent launch of the new 5 year advertising solution from MillionPixelClick.com means the pixel advertising craze will continue unabated. Selling advertising space by the...
13
by: Martijn Mulder | last post by:
I try to define a line with the length of 1 unit (1 pixel) that is, in fact, just a point on the screen. But when I draw it with a wide pen with the appropriate StartCap and EndCap (Round), it will...
33
by: Dave (DreamIsle) | last post by:
Hello. I'm working on a layout that I need to be pixel specific. How can I get the font to stay precisely the height I need? Specifying line-height or font-size in px doesn't yield the results I...
30
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
8
by: ofiras | last post by:
Hi, I made a "Paint" program, but I couldn't find a method to paint 1 pixel using graphic state ("Graphics g = Graphics.FromHwnd(this.Handle);") How can I paint 1 pixel? I guess I can make a...
1
by: ofiras | last post by:
In bitmap, how can I find the nearest pixel (pixel 1) to a specific pixel (pixel 2) that has different color from pixel 2? Or how can I find a pixel in a specific distance from pixel 2 (like a...
9
by: raylopez99 | last post by:
After refering to the below thread, I take it for C# Forms 2.0, there a way to draw a 1 pixel by 1 pixel rectangle, which I was able to do just now successfully. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...
0
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...

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.