473,387 Members | 1,548 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,387 software developers and data experts.

Can't graphics to display

I am trying to build graphic charts in a vb.net module callable from another
form. I have translated this code from VB6 where it worked well. I can
make the code work to bring up and display the form and its command buttons.
I can track the code execution with debug. However, I cannot change the
background color of the form or see any of the drawline or drawtext
functions. Here are a few relevant lines of code:

Module SMPLOT3

Dim f As New Market_Charts.Form2()

Dim g As Graphics = f.CreateGraphics

f.BackColor = System.Drawing.Color.Black

g.DrawString(ymn1, myFont, New SolidBrush(Color.Yellow), currentx, currenty)

Any ideas?

Harley


Jan 30 '07 #1
3 1589
On Jan 29, 11:29 pm, "Harley" <harleyfeld...@msn.comwrote:
I am trying to build graphic charts in a vb.net module callable from another
form. I have translated this code from VB6 where it worked well. I can
make the code work to bring up and display the form and its command buttons.
I can track the code execution with debug. However, I cannot change the
background color of the form or see any of the drawline or drawtext
functions. Here are a few relevant lines of code:

Module SMPLOT3

Dim f As New Market_Charts.Form2()

Dim g As Graphics = f.CreateGraphics

f.BackColor = System.Drawing.Color.Black

g.DrawString(ymn1, myFont, New SolidBrush(Color.Yellow), currentx, currenty)

Any ideas?

Harley
Yes, don't use CreateGraphics to grab a drawing handle from your
form. Instead, override the OnPaint method of the form and do you
painting there using the graphics object supplied.

See this website for additional information: www.bobpowell.net

Chris

Feb 2 '07 #2
Chris,

Thanks for the input, and I understand what you are saying. However, not
being a VB.net wizard, I am still struggling to make my code work. The
major issue is that while the main code is executing under Form2, I am
calling a module with the actual plotting routines. How do I set up the
main routine and the plotting module for the Paint Event Handler? Every
example that I see has the graphics code in the same modulke as the form. I
can do this, but I perfer not to.

Thanks,

Harley
Feb 6 '07 #3
On Feb 6, 10:47 am, "Harley" <harleyfeld...@msn.comwrote:
Chris,

Thanks for the input, and I understand what you are saying. However, not
being a VB.net wizard, I am still struggling to make my code work. The
major issue is that while the main code is executing under Form2, I am
calling a module with the actual plotting routines. How do I set up the
main routine and the plotting module for the Paint Event Handler? Every
example that I see has the graphics code in the same modulke as the form. I
can do this, but I perfer not to.

Thanks,

Harley
If you want to keep your graphics routines in a separate module, then
pass the items you need from the paint event to the method in the
module. For example:

'Paint event in the form class
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Using f As New Font("Arial", 30, FontStyle.Bold,
GraphicsUnit.Pixel)
GraphicsMethods.DoSomeDrawing(e.Graphics, "Draw Me", f, New
PointF(22, 450))
End Using
End Sub

'Module called GraphicsMethods

Imports System.Drawing

Module GraphicsMethods

Public Sub DoSomeDrawing(ByVal g As Graphics, ByVal textToDraw As
String, ByVal fnt As Font, ByVal location As PointF)
g.DrawString(textToDraw, fnt, Brushes.Black, location)
End Sub

End Module


Feb 6 '07 #4

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

Similar topics

5
by: sank | last post by:
Hello all, I want to display graphics file (BMP/JPEG/GIF) on the console in c++... help...
1
by: Yaron | last post by:
Hi, I made a procedure which receives a Graphics parameter, and with that Graphics parameter, performs various things. The area of confusion here is that when I pass the procedure a Graphics...
4
by: Peter Oliphant | last post by:
There doesn't seem to be any documentation on how to create and/or use an instance of System::Drawing::Graphics. On-line MSDN talks about this class, and says: " The Graphics class provides...
1
by: Martin Raychev | last post by:
Hi everyone, I have to design an application which has to display some graphics of maritime data. I am wondering whether it could be web application (ASP.NET) or standalone C# application.
5
by: Carlos Ojea Castro | last post by:
Hello: I want to display graphics from my postgresql database, but I must choose the proper tool first. Which one is more suitable?: perl? php? pg_autodoc? another one?
1
by: Harley | last post by:
I am trying to build graphic charts in a vb.net module callable from another form. I have translated this code from VB6 where it worked well. I can make the code work to bring up and display the...
3
by: KSprairie | last post by:
Don't ya just love getting all the way done with a website, then discover a major problem?! :) In IE6, please check out http://dev.prairiepublishing.com/about/aboutabc.shtml. There should be two...
5
by: simon | last post by:
hello, I have a server set up on my local (home) network and can not get an ajax application to run on the box. it works fine on our developement server and also works fine locally. I...
4
by: AWW | last post by:
XP VB 2005 drawing line graphics in a PictureBox - from a simple minded former FORTRAN programmer. The help examples have the graphics drawing code (lines & rectangles) in the PictureBox paint...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.