vb.net 2k3:
I have this code that doesn't work unless I take out the g.DrawString
statements. If anyone can look over the code and tell me why I'd appreciate
it.
Dim g As Graphics
Dim LabelText As String
LabelText = "--"
x = x + 20
Dim varSlash As String
varSlash = "/"
Dim brushColor As System.Drawing. Color
Dim blackBrush = New SolidBrush(Syst emColors.Window Text)
Dim blueBrush = New SolidBrush(brus hColor.Blue)
Dim greenBrush = New SolidBrush(brus hColor.Green)
Dim redBrush = New SolidBrush(brus hColor.Red)
Dim yellowBrush = New SolidBrush(brus hColor.Yellow)
Dim grayBrush = New SolidBrush(brus hColor.Gray)
Dim labelFont As New Font("Arial", 40)
Dim format As New StringFormat
format.Alignmen t = StringAlignment .Center
format.LineAlig nment = StringAlignment .Center
y = 200
g.DrawString(va rSection.ToStri ng, Font, blackBrush, x, y)
y = y + 15
g.DrawString(La belText.ToStrin g, Font, blackBrush, x, y)
y = y + 5
g.DrawString(va rCheckList.ToSt ring, Font, blackBrush, x, y)
y = y + 50
g.DrawString(va rValidated.ToSt ring, Font, blueBrush, x, y)
y = y + 10
g.DrawString(va rSlash.ToString , Font, blackBrush, x, y)
y = y + 10
g.DrawString(va rAwaiting.ToStr ing, Font, greenBrush, x, y)
y = y + 10
g.DrawString(va rSlash.ToString , Font, blackBrush, x, y)
y = y + 10
g.DrawString(va rNot.ToString, Font, redBrush, x, y)
y = y + 10
g.DrawString(va rSlash.ToString , Font, blackBrush, x, y)
y = y + 10
g.DrawString(va rFollow.ToStrin g, Font, yellowBrush, x, y)
y = y + 10
g.DrawString(va rSlash.ToString , Font, blackBrush, x, y)
y = y + 10
g.DrawString(va rNA.ToString, Font, grayBrush, x, y) 5 1222
You have only set "g" to a type of Graphics. You don't have a graphics
object to draw on. You need to create a graphics object from either a
control or a bitmap;
dim g as graphics = mycontrol.Creat eGraphics
or
dim mybitmap As Bitmap = New Bitmap(Width, Height)
dim g as Graphics = Graphics.FromIm age(v_BackImage )
"brix_zx2" wrote: vb.net 2k3:
I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it.
Dim g As Graphics Dim LabelText As String LabelText = "--" x = x + 20 Dim varSlash As String varSlash = "/"
Dim brushColor As System.Drawing. Color Dim blackBrush = New SolidBrush(Syst emColors.Window Text) Dim blueBrush = New SolidBrush(brus hColor.Blue) Dim greenBrush = New SolidBrush(brus hColor.Green) Dim redBrush = New SolidBrush(brus hColor.Red) Dim yellowBrush = New SolidBrush(brus hColor.Yellow) Dim grayBrush = New SolidBrush(brus hColor.Gray) Dim labelFont As New Font("Arial", 40) Dim format As New StringFormat format.Alignmen t = StringAlignment .Center format.LineAlig nment = StringAlignment .Center
y = 200 g.DrawString(va rSection.ToStri ng, Font, blackBrush, x, y) y = y + 15 g.DrawString(La belText.ToStrin g, Font, blackBrush, x, y) y = y + 5 g.DrawString(va rCheckList.ToSt ring, Font, blackBrush, x, y) y = y + 50 g.DrawString(va rValidated.ToSt ring, Font, blueBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rAwaiting.ToStr ing, Font, greenBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNot.ToString, Font, redBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rFollow.ToStrin g, Font, yellowBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNA.ToString, Font, grayBrush, x, y)
Sorry, I forgot to change one of my variables...her e is the corrected code:
You have only set "g" to a type of Graphics. You don't have a graphics
object to draw on. You need to create a graphics object from either a
control or a bitmap;
dim g as graphics = mycontrol.Creat eGraphics
or
dim mybitmap As Bitmap = New Bitmap(Width, Height)
dim g as Graphics = Graphics.FromIm age(mybitmap)
"brix_zx2" wrote: vb.net 2k3:
I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it.
Dim g As Graphics Dim LabelText As String LabelText = "--" x = x + 20 Dim varSlash As String varSlash = "/"
Dim brushColor As System.Drawing. Color Dim blackBrush = New SolidBrush(Syst emColors.Window Text) Dim blueBrush = New SolidBrush(brus hColor.Blue) Dim greenBrush = New SolidBrush(brus hColor.Green) Dim redBrush = New SolidBrush(brus hColor.Red) Dim yellowBrush = New SolidBrush(brus hColor.Yellow) Dim grayBrush = New SolidBrush(brus hColor.Gray) Dim labelFont As New Font("Arial", 40) Dim format As New StringFormat format.Alignmen t = StringAlignment .Center format.LineAlig nment = StringAlignment .Center
y = 200 g.DrawString(va rSection.ToStri ng, Font, blackBrush, x, y) y = y + 15 g.DrawString(La belText.ToStrin g, Font, blackBrush, x, y) y = y + 5 g.DrawString(va rCheckList.ToSt ring, Font, blackBrush, x, y) y = y + 50 g.DrawString(va rValidated.ToSt ring, Font, blueBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rAwaiting.ToStr ing, Font, greenBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNot.ToString, Font, redBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rFollow.ToStrin g, Font, yellowBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNA.ToString, Font, grayBrush, x, y)
"brix_zx2" <br*****@discus sions.microsoft .com> schrieb: I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it.
Dim g As Graphics
If you are using the code inside a form's or control's 'OnPaint' method or
'Paint' event handler, add this line:
\\\
g = e.Graphics
///
Dim LabelText As String LabelText = "--" x = x + 20 Dim varSlash As String varSlash = "/"
Dim brushColor As System.Drawing. Color Dim blackBrush = New SolidBrush(Syst emColors.Window Text) Dim blueBrush = New SolidBrush(brus hColor.Blue) Dim greenBrush = New SolidBrush(brus hColor.Green) Dim redBrush = New SolidBrush(brus hColor.Red) Dim yellowBrush = New SolidBrush(brus hColor.Yellow) Dim grayBrush = New SolidBrush(brus hColor.Gray) Dim labelFont As New Font("Arial", 40) Dim format As New StringFormat format.Alignmen t = StringAlignment .Center format.LineAlig nment = StringAlignment .Center
y = 200 g.DrawString(va rSection.ToStri ng, Font, blackBrush, x, y) y = y + 15
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
You have to get a Graphics object. The one you have is declared but is just
a placeholder.
Perhaps you might use
dim g as Graphics = e.Graphics
if you were responding to a Paint event o perhaps...
dim e as Graphics=Graphi cs.FromImage(.. .)
if you were drawing on an in-memory bitmap.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"brix_zx2" <br*****@discus sions.microsoft .com> wrote in message
news:DB******** *************** ***********@mic rosoft.com... vb.net 2k3:
I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it.
Dim g As Graphics Dim LabelText As String LabelText = "--" x = x + 20 Dim varSlash As String varSlash = "/"
Dim brushColor As System.Drawing. Color Dim blackBrush = New SolidBrush(Syst emColors.Window Text) Dim blueBrush = New SolidBrush(brus hColor.Blue) Dim greenBrush = New SolidBrush(brus hColor.Green) Dim redBrush = New SolidBrush(brus hColor.Red) Dim yellowBrush = New SolidBrush(brus hColor.Yellow) Dim grayBrush = New SolidBrush(brus hColor.Gray) Dim labelFont As New Font("Arial", 40) Dim format As New StringFormat format.Alignmen t = StringAlignment .Center format.LineAlig nment = StringAlignment .Center
y = 200 g.DrawString(va rSection.ToStri ng, Font, blackBrush, x, y) y = y + 15 g.DrawString(La belText.ToStrin g, Font, blackBrush, x, y) y = y + 5 g.DrawString(va rCheckList.ToSt ring, Font, blackBrush, x, y) y = y + 50 g.DrawString(va rValidated.ToSt ring, Font, blueBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rAwaiting.ToStr ing, Font, greenBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNot.ToString, Font, redBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rFollow.ToStrin g, Font, yellowBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNA.ToString, Font, grayBrush, x, y)
You especially DO NOT use CreateGraphics!
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:3E******** *************** ***********@mic rosoft.com... You have only set "g" to a type of Graphics. You don't have a graphics object to draw on. You need to create a graphics object from either a control or a bitmap;
dim g as graphics = mycontrol.Creat eGraphics
or
dim mybitmap As Bitmap = New Bitmap(Width, Height) dim g as Graphics = Graphics.FromIm age(v_BackImage )
"brix_zx2" wrote:
vb.net 2k3:
I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it.
Dim g As Graphics Dim LabelText As String LabelText = "--" x = x + 20 Dim varSlash As String varSlash = "/"
Dim brushColor As System.Drawing. Color Dim blackBrush = New SolidBrush(Syst emColors.Window Text) Dim blueBrush = New SolidBrush(brus hColor.Blue) Dim greenBrush = New SolidBrush(brus hColor.Green) Dim redBrush = New SolidBrush(brus hColor.Red) Dim yellowBrush = New SolidBrush(brus hColor.Yellow) Dim grayBrush = New SolidBrush(brus hColor.Gray) Dim labelFont As New Font("Arial", 40) Dim format As New StringFormat format.Alignmen t = StringAlignment .Center format.LineAlig nment = StringAlignment .Center
y = 200 g.DrawString(va rSection.ToStri ng, Font, blackBrush, x, y) y = y + 15 g.DrawString(La belText.ToStrin g, Font, blackBrush, x, y) y = y + 5 g.DrawString(va rCheckList.ToSt ring, Font, blackBrush, x, y) y = y + 50 g.DrawString(va rValidated.ToSt ring, Font, blueBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rAwaiting.ToStr ing, Font, greenBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNot.ToString, Font, redBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rFollow.ToStrin g, Font, yellowBrush, x, y) y = y + 10 g.DrawString(va rSlash.ToString , Font, blackBrush, x, y) y = y + 10 g.DrawString(va rNA.ToString, Font, grayBrush, x, y) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve |
last post by:
Hi all
I am using the following code to draw strings onto a Form:
----------------------------
Dim tabGraphics As System.Drawing.Graphics = Me.CreateGraphics()
Dim labelFont As New Font("Verdana", 12, FontStyle.Regular, GraphicsUnit.Pixel)
Dim solidBrush As New SolidBrush(Color.DarkSlateBlue)
---------------------------
|
by: Hadar |
last post by:
Hi,
I'm getting "object is currently in use elsewhere" when I use
System.Drawing.Graphics.MesureString.
This is what I do:
My controls use a utility class the helps it to mesure strings.
To get the best performance for the utility class, its members, as well as
the System.Drawing.Graphics object, are static:
|
by: Rod Gill |
last post by:
Hi,
I have a form that when opened in the designer appears of the screen. The
form selector can't be dragged (or resized) and if I scroll right and down
to centralise it the form simply jumps further away, completely leaving the
selector box area.
Any ideas? VS 2003 and VB.Net
This is a simple application at the moment but the form is inherited from a
|
by: asdf |
last post by:
I just started my first project where i draw lines and strings on the
screen. I sucessfully drew what i needed on the screen, then realized that
when it updated it just drew over the same area w/o clearing the first
instance of text and lines. How can i clear it? Below is my code,
basically it is a thermometer and my program is drawing a red line the
height of the temp and drawing the temp on the red bubble.
Dim g As Graphics
|
by: lodhaakhil85 |
last post by:
Hi
I'm a newbie to C# and GDI+.I am writing an application that will
display some strings from a file on a panel. There are a few of
problems I am facing :
1.How do make the panel re-adjust its size when maximizing the form
window ??
2. I'm drawing the strings on the panel. if the number of strings
exceeds those that can be displayed in the panel, how can I add a
| |
by: lodhaakhil85 |
last post by:
Hi,
I am graphics object of the panel to draw Strings on the panel, but
when I scroll down I cannot see the remaining strings and when I move
up the scroll bar the orginial strings that were visible initially seem
to get erased ?? What's happening ne Idea ??
Thanks,
Akhil
|
by: mehdi_mousavi |
last post by:
Hi folks,
Consider a text containing 200 characters (more or less) including
and/or excluding the CR/LF within. I would like to compute the height
of this text whenever it's width is limited by X pixels! i.e., what's
the height of the mentioned text when it's being automatically word
wrapped within a rectangle of WIDTH pixels? How am I supposed to
calculate the height required to show the message?
TIA,
Mehdi
|
by: Irfan |
last post by:
hi,
I have a fileName stored as a string as shown:
String fn = @"C:\drawing\testdrawings\test;
which gives fn = "C:\\drawing\\testdrawings\\test;
however i dont want '\' to get converted to '\\'
The reason i need to remove one of the '\' is because, i have a dataTable
where I search for the files using
|
by: pod |
last post by:
Hello
My OS is Windows2000
I am new to .NET
I developed a C# Windows Application that connects to a MS Access database on the network using proper UNC format.
It works perfectly on my main machine (from which I have developed it).
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |