Click here to Skip to main content
15,561,246 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Background color of message box Pin
Dave Kreskowiak5-Mar-10 3:02
mveDave Kreskowiak5-Mar-10 3:02 
QuestionOffice Interop Exception in VB.NET1.1, Please help Pin
Puneet Bhatnagar4-Mar-10 2:53
Puneet Bhatnagar4-Mar-10 2:53 
QuestionGDI+ help Pin
nyt19724-Mar-10 0:43
professionalnyt19724-Mar-10 0:43 
AnswerRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 1:50
professionalWayne Gaylard4-Mar-10 1:50 
AnswerRe: GDI+ help Pin
Dave Kreskowiak4-Mar-10 2:53
mveDave Kreskowiak4-Mar-10 2:53 
GeneralRe: GDI+ help Pin
nyt19724-Mar-10 20:24
professionalnyt19724-Mar-10 20:24 
GeneralRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 22:31
professionalWayne Gaylard4-Mar-10 22:31 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 1:01
professionalnyt19725-Mar-10 1:01 
Dear Following is my code and below that is the error I get:


<pre>Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Public Class Form1

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim g As Graphics = e.Graphics
g.DrawString(TextBox1.Text, New Font("Verdana", 15), New SolidBrush(Color.Red), New PointF(20, 20))
g.DrawString(TextBox1.Text, New Font("Arial", 12), New SolidBrush(Color.Blue), New PointF(20, 50))
g.Dispose()

End Sub


Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
e.KeyChar = ChrW(AscW(CommonFunctions.AsciiToUnicode(AscW(e.KeyChar))))
End Sub



Private Sub Label1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
Dim g As Graphics = e.Graphics
g.DrawString(TextBox1.Text, New Font("Verdana", 15), New SolidBrush(Color.Red), New PointF(20, 20))

g.Dispose()
End Sub



Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Refresh()
End Sub

End Class</pre>




<b>Error I get</b>

&lt;
System.ArgumentException was unhandled
Message="Parameter is not valid."
Source="System.Drawing"
StackTrace:
at System.Drawing.Graphics.GetHdc()
at System.Drawing.BufferedGraphics.RenderInternal(HandleRef refTargetDC, BufferedGraphics buffer)
at System.Drawing.BufferedGraphics.Render()
at System.Windows.Forms.Control.WmPaint(Message&amp; m)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.Label.WndProc(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at DrawStringMethodGDI_.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

&gt;
GeneralRe: GDI+ help Pin
Wayne Gaylard5-Mar-10 1:57
professionalWayne Gaylard5-Mar-10 1:57 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 2:13
professionalnyt19725-Mar-10 2:13 
GeneralRe: GDI+ help Pin
Wayne Gaylard5-Mar-10 2:51
professionalWayne Gaylard5-Mar-10 2:51 
GeneralRe: GDI+ help Pin
Dave Kreskowiak5-Mar-10 3:10
mveDave Kreskowiak5-Mar-10 3:10 
AnswerRe: GDI+ help Pin
Luc Pattyn5-Mar-10 2:55
sitebuilderLuc Pattyn5-Mar-10 2:55 
GeneralRe: GDI+ help Pin
nyt19727-Mar-10 21:35
professionalnyt19727-Mar-10 21:35 
QuestionWorking with CR in VB.net Pin
C#Coudou4-Mar-10 0:03
C#Coudou4-Mar-10 0:03 
AnswerRe: Working with CR in VB.net Pin
Anubhava Dimri4-Mar-10 19:25
Anubhava Dimri4-Mar-10 19:25 
QuestionHow to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
karthickmani633-Mar-10 18:31
karthickmani633-Mar-10 18:31 
AnswerRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
Dalek Dave3-Mar-10 22:47
professionalDalek Dave3-Mar-10 22:47 
GeneralRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
karthickmani634-Mar-10 0:33
karthickmani634-Mar-10 0:33 
GeneralRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
Dave Kreskowiak4-Mar-10 2:47
mveDave Kreskowiak4-Mar-10 2:47 
QuestionReferences Pin
neverpleat3-Mar-10 13:45
neverpleat3-Mar-10 13:45 
AnswerRe: References Pin
Dave Kreskowiak4-Mar-10 2:44
mveDave Kreskowiak4-Mar-10 2:44 
GeneralRe: References Pin
neverpleat4-Mar-10 4:00
neverpleat4-Mar-10 4:00 
GeneralRe: References Pin
Dave Kreskowiak4-Mar-10 4:30
mveDave Kreskowiak4-Mar-10 4:30 
GeneralRe: References [modified] Pin
neverpleat4-Mar-10 4:49
neverpleat4-Mar-10 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.