Click here to Skip to main content
15,566,264 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Change workbook for read/ write Pin
Dave Kreskowiak4-Mar-10 12:06
mveDave Kreskowiak4-Mar-10 12:06 
QuestionBackground color of message box Pin
Tufail Ahmad4-Mar-10 3:47
Tufail Ahmad4-Mar-10 3:47 
AnswerRe: Background color of message box Pin
Dave Kreskowiak4-Mar-10 4:44
mveDave Kreskowiak4-Mar-10 4:44 
GeneralRe: Background color of message box Pin
Tufail Ahmad4-Mar-10 19:05
Tufail Ahmad4-Mar-10 19:05 
GeneralRe: Background color of message box Pin
Anubhava Dimri4-Mar-10 19:19
Anubhava Dimri4-Mar-10 19:19 
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 
Hi friends,

I wrote this code to display graphical text on form as well in label control but it has two problems.

1. It display the graphical text on form when I move mouse on a button on the form.

2. It dosnt show anything in label

Pls help.

<code>
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 System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
'Create a Graphics object
Dim g As Graphics = Me.CreateGraphics()
'Create font families
Dim verdanaFamily As New FontFamily("Verdana")
Dim arialFamily As New FontFamily("Arial")
AddHandler Label1.Paint, AddressOf Me.Label1_Paint

'Construct font objects
Dim verdanaFont As New Font("Verdana", 10)
Dim arialFont As New Font(arialFamily, 16, FontStyle.Bold)
Dim tahomaFont As New Font("Tahoma", 24, FontStyle.Underline Or FontStyle.Italic)


'Create Brush and other objects
Dim pointF As New PointF(30, 10)
Dim solidBrush As New SolidBrush(Color.FromArgb(255, 0, 0, 255))
'Draw text using DrawString
g.DrawString(TextBox1.Text, verdanaFont, New SolidBrush(Color.Red), New PointF(20, 20))
g.DrawString(TextBox1.Text, arialFont, New SolidBrush(Color.Blue), New PointF(20, 50))

'Dispose of objects
SolidBrush.Dispose()
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
'Create a Graphics object
Dim g As Graphics = Label1.CreateGraphics
'Create font families

'Construct font objects

Dim tahomaFont As New Font("Tahoma", 24, FontStyle.Underline Or FontStyle.Italic)

'Create Brush and other objects
Dim pointF As New PointF(30, 10)
Dim solidBrush As New SolidBrush(Color.FromArgb(255, 0, 0, 255))
g.DrawString(TextBox1.Text, tahomaFont, New SolidBrush(Color.Green), Label1.Location.X, Label1.Location.Y)
'Dispose of objects
solidBrush.Dispose()
g.Dispose()
End Sub

Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
Dim fnt As New Font("Verdana", 16)

Dim g As Graphics = pe.Graphics
g.DrawString(TextBox1.Text, fnt, New SolidBrush(Color.Red), 14, 10)

End Sub 'OnPaint

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

</code>
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 
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 

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.