Get Video VB.Net Tutorials here…

This post is for computer programmers. If this is gobbly-gook to you then move along…nothing to see here!

I had to drop this little tid-bit for anyone who programs with VB.Net 2005 SP2. If you attempt to programmatically create a control and then wish to add a tooltip or cursor to the control, make sure that you are not drawing any graphics from Visual Basic Power Pack 2.0 or 3.0 first. They must be drawn after creating the controls. If you draw them first you will be screwed!

I have just spent the last 3 days pulling out my hair trying to add a simple tooltip and cursor to a programmatically created label. I spent the same three days posting in a couple of newsgroups to see what was going on.

Not even thinking about the graphics I posted my label code, revised label code, revised revised label code in an effort to find a solution. Everyone was telling me that my code worked. How come not for me? A Microsoft conspiracy against the Mad Ape?

NAH. I am not that paranoid or self-centered.

Anyway, the bottom line is when you are programmatically creating tool tips and cursors for programmatically created labels, draw the graphics last, not first.

Get Video VB.Net Tutorials here…

Here is some code for those that are interested:

For Each tp As TabPage In tabResults.TabPages

Dim tabLblPulp As New Label
tabLblPulp.Location = New Point(14, 121)
tabLblPulp.Size = New Size(54, 13)
tabLblPulp.Name = tp.Text & “MYLABEL”
tabLblPulp.Text = “LABEL TEXT”
tabLblPulp.ForeColor = Color.Blue
tabLblPulp.Cursor = Cursors.Hand
tabLblPulp.Visible = True
tabLblPulp.Font = New System.Drawing.Font(”Microsoft Sans Serif”, 8.25!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
tp.Controls.Add(tabLblPulp)

ToolTip1.SetToolTip(tabLblPulp, “MY TOOLTIP TEXT”)

Dim sContainer As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim tabRect As New Microsoft.VisualBasic.PowerPacks.RectangleShape
tabRect.Location = New System.Drawing.Point(3, 46)
tabRect.Size = New System.Drawing.Size(809, 436)
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabRect)

Dim tabLin1 As New Microsoft.VisualBasic.PowerPacks.LineShape
tabLin1.X1 = 4
tabLin1.X2 = 812
tabLin1.Y1 = 90
tabLin1.Y2 = 90
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabLin1)

Dim tabLin2 As New Microsoft.VisualBasic.PowerPacks.LineShape
tabLin2.X1 = 4
tabLin2.X2 = 812
tabLin2.Y1 = 156
tabLin2.Y2 = 156
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabLin2)

Dim tabLin3 As New Microsoft.VisualBasic.PowerPacks.LineShape
tabLin3.X1 = 4
tabLin3.X2 = 812
tabLin3.Y1 = 222
tabLin3.Y2 = 222
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabLin3)

Dim tabLin4 As New Microsoft.VisualBasic.PowerPacks.LineShape
tabLin4.X1 = 4
tabLin4.X2 = 812
tabLin4.Y1 = 288
tabLin4.Y2 = 288
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabLin4)

Dim tabLin5 As New Microsoft.VisualBasic.PowerPacks.LineShape
tabLin5.X1 = 4
tabLin5.X2 = 812
tabLin5.Y1 = 354
tabLin5.Y2 = 354
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabLin5)

Dim tabLin6 As New Microsoft.VisualBasic.PowerPacks.LineShape
tabLin6.X1 = 4
tabLin6.X2 = 812
tabLin6.Y1 = 420
tabLin6.Y2 = 420
sContainer.BackColor = Color.White
sContainer.Shapes.Add(tabLin6)

tp.Controls.Add(sContainer)

Next

Get Video VB.Net Tutorials here…

Technorati Tags: , , , , , , , , ,

sign up for banana peels :