Click here to Skip to main content
15,927,699 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Background color of message box Pin
Dave Kreskowiak5-Mar-10 2:02
mveDave Kreskowiak5-Mar-10 2:02 
QuestionOffice Interop Exception in VB.NET1.1, Please help Pin
Puneet Bhatnagar4-Mar-10 1:53
Puneet Bhatnagar4-Mar-10 1:53 
QuestionGDI+ help Pin
nyt19723-Mar-10 23:43
professionalnyt19723-Mar-10 23:43 
AnswerRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 0:50
professionalWayne Gaylard4-Mar-10 0:50 
AnswerRe: GDI+ help Pin
Dave Kreskowiak4-Mar-10 1:53
mveDave Kreskowiak4-Mar-10 1:53 
GeneralRe: GDI+ help Pin
nyt19724-Mar-10 19:24
professionalnyt19724-Mar-10 19:24 
GeneralRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 21:31
professionalWayne Gaylard4-Mar-10 21:31 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 0:01
professionalnyt19725-Mar-10 0: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 0:57
professionalWayne Gaylard5-Mar-10 0:57 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 1:13
professionalnyt19725-Mar-10 1:13 
GeneralRe: GDI+ help Pin
Wayne Gaylard5-Mar-10 1:51
professionalWayne Gaylard5-Mar-10 1:51 
GeneralRe: GDI+ help Pin
Dave Kreskowiak5-Mar-10 2:10
mveDave Kreskowiak5-Mar-10 2:10 
AnswerRe: GDI+ help Pin
Luc Pattyn5-Mar-10 1:55
sitebuilderLuc Pattyn5-Mar-10 1:55 
GeneralRe: GDI+ help Pin
nyt19727-Mar-10 20:35
professionalnyt19727-Mar-10 20:35 
QuestionWorking with CR in VB.net Pin
C#Coudou3-Mar-10 23:03
C#Coudou3-Mar-10 23:03 
AnswerRe: Working with CR in VB.net Pin
Anubhava Dimri4-Mar-10 18:25
Anubhava Dimri4-Mar-10 18:25 
QuestionHow to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
karthickmani633-Mar-10 17:31
karthickmani633-Mar-10 17:31 
AnswerRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
Dalek Dave3-Mar-10 21:47
professionalDalek Dave3-Mar-10 21:47 
GeneralRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
karthickmani633-Mar-10 23:33
karthickmani633-Mar-10 23:33 
GeneralRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
Dave Kreskowiak4-Mar-10 1:47
mveDave Kreskowiak4-Mar-10 1:47 
QuestionReferences Pin
neverpleat3-Mar-10 12:45
neverpleat3-Mar-10 12:45 
AnswerRe: References Pin
Dave Kreskowiak4-Mar-10 1:44
mveDave Kreskowiak4-Mar-10 1:44 
GeneralRe: References Pin
neverpleat4-Mar-10 3:00
neverpleat4-Mar-10 3:00 
GeneralRe: References Pin
Dave Kreskowiak4-Mar-10 3:30
mveDave Kreskowiak4-Mar-10 3:30 
GeneralRe: References [modified] Pin
neverpleat4-Mar-10 3:49
neverpleat4-Mar-10 3: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.