Cant create 2nd textbox - vb.net

I'm having problems with this code and I can't figure out why. It works fine the first time through but crashes with a "Parameter is not Valid" error the 2nd time through on this line:
Dim tbx As TextBox = New Windows.Forms.TextBox
The full code is as follows:
Dim tbx As TextBox = New Windows.Forms.TextBox
tbx.Name = tbxName
tbx.Size = New System.Drawing.Size(55, 12)
tbx.BorderStyle = BorderStyle.None
tbx.TextAlign = HorizontalAlignment.Center
Using f As Font = tbx.Font
tbx.Font = New Font(f.FontFamily, 8, FontStyle.Bold)
End Using
tbx.Location = New System.Drawing.Point(xCords, 44)
Select Case tbx.Name
Case "tbxBulk01" : tbx.Text = Bulk01Label
Case "tbxBulk02" : tbx.Text = Bulk02Label
End Select
Me.Controls.Add(tbx)
Here's the stack trace:
at System.Drawing.Font.GetHeight(Graphics graphics)
at System.Drawing.Font.GetHeight()
at System.Drawing.Font.get_Height()
at System.Windows.Forms.Control.get_FontHeight()
at System.Windows.Forms.TextBoxBase.get_PreferredHeight()
at System.Windows.Forms.TextBoxBase.get_DefaultSize()
at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)
at System.Windows.Forms.TextBoxBase..ctor()
at System.Windows.Forms.TextBox..ctor()
Any help is appreciated.

I know this is an old question but here is my answer.
I suspected the
USING .... END USING section as well.
I have just read that in the feedback too, oh well, never mind.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xCoords As Integer = 80
Dim myTextBox As TextBox = New TextBox
For index As Integer = 1 To 2
myTextBox = New TextBox
myTextBox.Name = "MyTextBox" & index.ToString
myTextBox.Size = New System.Drawing.Size(55, 12)
myTextBox.BorderStyle = BorderStyle.None
myTextBox.TextAlign = HorizontalAlignment.Center
myTextBox.Font = New System.Drawing.Font(myTextBox.Font.FontFamily, 8, FontStyle.Bold)
myTextBox.Location = New System.Drawing.Point(index * xCoords, 44)
Select Case index
Case 1 : myTextBox.Text = "Bulk01Label"
Case 2 : myTextBox.Text = "Bulk02Label"
End Select
Me.Controls.Add(myTextBox)
Next
End Sub
End Class

Related

How to stop controls from flickering during MouseMove Event

I know this is a pretty popular question, but none of the solutions I have found have worked for me.
Background: I have a windows forms project in VS2015 that reads data from text files and plots the data as multiple series on a line chart. The Chart.MouseMove event finds the point nearest the mouse and draws a circle around it. The circle is drawn in the Chart_Paint event
Private Sub crtLogView(sender As Object,e As PaintEventArgs) Handles crtLogView.Paint
Dim whitePen as New Pne(Color.White,2)
e.Graphics.DrawEllipse(whitePen,cir) '//cir is a Public Rectangle
End Sub
When moving the mouse across the chart, random controls flicker off then back on which is very annoying. I have posted the MouseMove event code below.
Potential solutions I have tried:
Turning on the DoubleBuffered property of the form, which does nothing
Using the Me.Invalidate() and Me.Update() method, which does not move the circle
Using the Chart.Invalidate() and Chart.Update() method, which works, but is very slow
Adding the following code to my Form_Load routine, which appears to do nothing
Any help with this would be greatly appreciated
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.UserPaint, True)
MouseMove Event Code:
Private Sub crtLogView_MouseMove(sender As Object, e As MouseEventArgs) Handles crtLogView.MouseMove
'//Show data for closest point to cursor & draw circle around point
Dim hResult As HitTestResult = crtLogView.HitTest(e.X, e.Y)
Dim srsNam As String = ""
Dim mouseY As Single
Dim pntDist As Double = 0
Dim pntX As Single
Dim pntY As Single
Dim mouseX As Single
On Error GoTo ErrTrap
'//Get X-Axis Position as integer
mouseX = Int(hResult.ChartArea.AxisX.PixelPositionToValue(e.X))
'// Set time value
lblTime.Text = String.Format("{0:n2}", hResult.ChartArea.AxisX.PixelPositionToValue(e.X) / 160)
'//Get Y-Axis Position
mouseY = hResult.ChartArea.AxisY.PixelPositionToValue(e.Y)
'//Get distance from mouse to point on Series(0)
pntDist = Math.Abs(crtLogView.Series(0).Points(mouseX).YValues(0) - mouseY)
srsNam = crtLogView.Series(0).Name '//1st series name
'//Find closest series
For i As Integer = 1 To crtLogView.Series.Count - 1
If Math.Abs(crtLogView.Series(i).Points(mouseX).YValues(0) - mouseY) < pntDist Then
pntDist = Math.Abs(crtLogView.Series(i).Points(mouseX).YValues(0) - mouseY)
srsNam = crtLogView.Series(i).Name
End If
Next
'//Set Top/Left values for circle
pntY = crtLogView.ChartAreas(0).AxisY.ValueToPixelPosition(crtLogView.Series(srsNam).Points(mouseX).YValues(0)) - 4
pntX = crtLogView.ChartAreas(0).AxisX.ValueToPixelPosition(Val(mouseX)) - 4
'//Move circle to closest point
cir.Location = New Point(pntX, pntY)
'//Refresh the form to move the circle
'//This works, but takes 2+ seconds to take effect
'crtLogView.Invalidate()
'crtLogView.Update()
'//This does not work
'Me.Invalidate()
'Me.Update()
'//This works, but randomly makes other controls flash/flicker
Me.Refresh()
ErrTrap:
End Sub
In the comments, I offered to provide an example of using a Chart Annotation or a DataPoint Label as an alternative to custom painting a circle around the point under the mouse-cursor and have included that in the code below. However, I realized that a DataPoint Marker should provide the function the OP is seeking and is likely the proper solution. Therefore, that option is also included.
Annotations are chart level graphics where-as the DataPoint Label and DataPoint Marker are as the name implies tied to the individual DataPoints. Proper sizing of annotations can be involved as their size is specified as a percentage of the Chart Area dimensions. This example does not attempt to resize the annotation based on the current chart size.
The following code sample is for a WinForm. In VS, add a new Class to a WinForm project and replace the auto-generated code with this. The set this Form as the startup Form.
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports Charting = System.Windows.Forms.DataVisualization.Charting
Public Class ChartDemo : Inherits Form
Const yMultiplyer As Double = 100.0
Private rnd As Random
Friend WithEvents chart As System.Windows.Forms.DataVisualization.Charting.Chart
Friend WithEvents rbAnnotation As System.Windows.Forms.RadioButton
Friend WithEvents rbDataLabel As System.Windows.Forms.RadioButton
Friend WithEvents rbMarker As System.Windows.Forms.RadioButton
Private lastPoint As Charting.DataPoint
Private ellispeAnnotation As Charting.EllipseAnnotation
Public Sub New()
InitializeComponent()
rnd = New Random(0) ' use same basis for each run
SetupChart()
End Sub
Private Sub InitializeComponent()
Me.chart = New System.Windows.Forms.DataVisualization.Charting.Chart()
Me.rbAnnotation = New System.Windows.Forms.RadioButton()
Me.rbDataLabel = New System.Windows.Forms.RadioButton()
Me.rbMarker = New System.Windows.Forms.RadioButton()
CType(Me.chart, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
Me.chart.Anchor = AnchorStyles.Top Or
AnchorStyles.Bottom Or
AnchorStyles.Left Or
AnchorStyles.Right
Me.chart.Location = New Point(4, 50)
Me.chart.Size = New Size(600, 500)
Me.rbAnnotation.AutoSize = True
Me.rbAnnotation.Location = New Point(50, 10)
Me.rbAnnotation.TabIndex = 1
Me.rbAnnotation.Text = "Use Annotation"
Me.rbAnnotation.UseVisualStyleBackColor = True
Me.rbDataLabel.AutoSize = True
Me.rbDataLabel.Location = New Point(200, 10)
Me.rbDataLabel.TabIndex = 2
Me.rbDataLabel.Text = "Use Data Label"
Me.rbDataLabel.UseVisualStyleBackColor = True
Me.rbMarker.AutoSize = True
Me.rbMarker.Location = New Point(400, 10)
Me.rbMarker.TabIndex = 3
Me.rbMarker.Text = "Use Data Marker"
Me.rbMarker.UseVisualStyleBackColor = True
Me.rbMarker.Checked = True
Me.AutoScaleDimensions = New SizeF(96.0!, 96.0!)
Me.AutoScaleMode = AutoScaleMode.Dpi
Me.ClientSize = New Size(610, 555)
Me.Controls.AddRange({Me.rbDataLabel, Me.rbAnnotation, Me.rbMarker, Me.chart})
Me.Text = "Charting Demo"
CType(Me.chart, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private Sub SetupChart()
chart.ChartAreas.Clear()
chart.Legends.Clear()
chart.Series.Clear()
chart.Annotations.Clear()
Dim area1 As New Charting.ChartArea("Area1")
chart.ChartAreas.Add(area1)
Dim ser As Charting.Series = chart.Series.Add("Series1")
ser.ChartArea = area1.Name
ser.ChartType = Charting.SeriesChartType.Line
' define defaults for point DataLabels
ser.LabelBorderColor = Color.Red
ser.LabelBorderWidth = 1
ser.LabelBackColor = Color.WhiteSmoke
ser.LabelForeColor = Color.Black
' define defaults for point DataMarkers
ser.MarkerSize = 10
ser.MarkerBorderWidth = 3
ser.MarkerBorderColor = Color.Red
ser.MarkerColor = Color.Transparent
' points for demo chart
For x As Double = -5.0 To 5.0
ser.Points.AddXY(x, rnd.NextDouble * yMultiplyer)
Next
ellispeAnnotation = CreateEllipseAnnotation()
ellispeAnnotation.Visible = False
chart.Annotations.Add(ellispeAnnotation)
End Sub
Private Sub chart_MouseLeave(sender As Object, e As EventArgs) Handles chart.MouseLeave
ellispeAnnotation.Visible = False
ClearLastPointDataLabel()
ClearLastPointMarker()
End Sub
Private Function CreateEllipseAnnotation() As Charting.EllipseAnnotation
Dim ret As New Charting.EllipseAnnotation()
ret.ForeColor = Color.Black
ret.Font = New Font("Arial", 10)
ret.LineWidth = 2
ret.Height = 7.5 ' % ChartArea height
ret.Width = 15 ' % ChartArea width
ret.BackColor = Color.PaleGoldenrod
ret.LineDashStyle = Charting.ChartDashStyle.Solid
Return ret
End Function
Private Sub chart_MouseMove(sender As Object, e As MouseEventArgs) Handles chart.MouseMove
Dim htr As Charting.HitTestResult = chart.HitTest(e.X, e.Y)
If htr.ChartElementType = Charting.ChartElementType.DataPoint Then
Dim pt As Charting.DataPoint = DirectCast(htr.Object, Charting.DataPoint)
If pt IsNot lastPoint Then
SetDataPointLabel(pt)
SetDataPointAnnotation(pt)
SetDataPointMarker(pt)
lastPoint = pt
End If
End If
End Sub
Private Sub SetDataPointAnnotation(pt As Charting.DataPoint)
If rbAnnotation.Checked Then
ellispeAnnotation.AnchorDataPoint = pt
ellispeAnnotation.Text = String.Format("{0:N2}, {1:N2}", pt.XValue, pt.YValues(0))
ellispeAnnotation.Visible = True
End If
End Sub
Private Sub SetDataPointLabel(pt As Charting.DataPoint)
ClearLastPointDataLabel()
If rbDataLabel.Checked Then
pt.Label = "#VALX{N2}, #VALY{N2}" ' case sensative, use uppercase for #VALX, #VALY
pt.IsValueShownAsLabel = True
End If
End Sub
Private Sub ClearLastPointDataLabel()
If lastPoint IsNot Nothing Then
lastPoint.Label = String.Empty
lastPoint.IsValueShownAsLabel = False
End If
End Sub
Private Sub SetDataPointMarker(pt As Charting.DataPoint)
ClearLastPointMarker()
If rbMarker.Checked Then pt.MarkerStyle = Charting.MarkerStyle.Circle
End Sub
Private Sub ClearLastPointMarker()
If lastPoint IsNot Nothing Then
lastPoint.MarkerStyle = Charting.MarkerStyle.None
End If
End Sub
Private Sub rbAnnotation_CheckedChanged(sender As Object, e As EventArgs) Handles rbAnnotation.CheckedChanged
If Not rbAnnotation.Checked Then
ellispeAnnotation.Visible = False
End If
End Sub
Private Sub rbDataLabel_CheckedChanged(sender As Object, e As EventArgs) Handles rbDataLabel.CheckedChanged
ClearLastPointDataLabel()
End Sub
Private Sub rbMarker_CheckedChanged(sender As Object, e As EventArgs) Handles rbMarker.CheckedChanged
ClearLastPointMarker()
End Sub
End Class

Generating rows of panels with for loop in VB.NET

I would like to create rows of panels with textboxes using a for loop.
The panels will be created inside another panel (MajorPanel).
The for loop's current value is used to assign values to the textboxes.
The number of rows will be determined by a form (form2) that has a textbox (RowNum) to input number of rows needed in the main form (form1) and use that information for the for loop's counter as shown:
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Ok.Click
Dim Rows As Integer
Rows = RowNum.Text 'RowNum is where to input number of rows needed in form1
Dim TxtBoxPanel As New Panel
Dim LeftBox As New TextBox
Dim CenterBox As New TextBox
Dim RightBox As New TextBox
Dim YAxis As Integer ' for adding TxtBoxPanel in new row
For index = 1 To Rows
'adding the textbox panel
Form1.MajorPanel.Controls.Add(TxtBoxPanel) 'referring to form1 as panel needed in form1
TxtBoxPanel.Name = ("txtBoxPanel" & index)
TxtBoxPanel.Size = New Size(610, 32)
YAxis = +32
TxtBoxPanel.Location = New Point(3, YAxis)
'adding left box
TxtBoxPanel.Controls.Add(LeftBox)
LeftBox.Name = ("LeftBox" & index)
LeftBox.Text = (index)
LeftBox.Size = New Size(100, 20)
LeftBox.Location = New Point(3, 3)
'adding center box
TxtBoxPanel.Controls.Add(CenterBox)
CenterBox.Name = ("CenterBox" & index)
CenterBox.Text = (index)
CenterBox.Size = New Size(100, 20)
CenterBox.Location = New Point(258, 3)
'adding right box
TxtBoxPanel.Controls.Add(RightBox)
RightBox.Name = ("RightBox" & index)
RightBox.Size = New Size(100, 20)
RightBox.Text = (index)
RightBox.Location = New Point(495, 3)
Next index
Close()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles RowNum.TextChanged
End Sub
End Class
However, when I execute, the panels generate one on top of the other as shown:
After execution for 23 rows
This is the desired result I would like:
Rows of panels within MajorPanel
form1 has only one line of code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form2.Show()
End Sub
End Class
In a quick glance, it looks like you are using YAxis = +32 when you should be using YAxis += 32.
The first one is just setting YAxis to the value 32, and the second one is incrementing it by 32, which is what you want (I assume)
There are two issues:
1- You are adding same instance of TxtBoxPanel to MajorPanel which means it will overwrite the previous location and you will end up only having single TxtBoxPanel at the bottom of MajorPanel because you are not creating new instead updating coordinates of same instance which got created before starting loop.
2- "YAxis = +32" should be "YAxis +=32
Here is updated code.. it should give you desired result.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Ok.Click
Dim Rows As Integer
Rows = RowNum.Text 'RowNum is where to input number of rows needed in form1
Dim YAxis As Integer ' for adding TxtBoxPanel in new row
For index = 1 To Rows
Dim TxtBoxPanel As New Panel
Dim LeftBox As New TextBox
Dim CenterBox As New TextBox
Dim RightBox As New TextBox
'adding the textbox panel
Form2.MajorPanel.Controls.Add(TxtBoxPanel) 'referring to form1 as panel needed in form1
TxtBoxPanel.Name = ("txtBoxPanel" & index)
TxtBoxPanel.Size = New Size(610, 32)
YAxis +=32
TxtBoxPanel.Location = New Point(3, YAxis)
'adding left box
TxtBoxPanel.Controls.Add(LeftBox)
LeftBox.Name = ("LeftBox" & index)
LeftBox.Text = (index)
LeftBox.Size = New Size(100, 20)
LeftBox.Location = New Point(3, 3)
'adding center box
TxtBoxPanel.Controls.Add(CenterBox)
CenterBox.Name = ("CenterBox" & index)
CenterBox.Text = (index)
CenterBox.Size = New Size(100, 20)
CenterBox.Location = New Point(258, 3)
'adding right box
TxtBoxPanel.Controls.Add(RightBox)
RightBox.Name = ("RightBox" & index)
RightBox.Size = New Size(100, 20)
RightBox.Text = (index)
RightBox.Location = New Point(495, 3)
Next index
Close()
End Sub

how to add some textbox with Code

i have trouble with this
Click Here for picture
The Code
Dim Tex1 As TextBox = Nothing
Dim Tex2 As TextBox = Nothing
Tex1 = New Windows.Forms.TextBox
Tex1.Name = "TextBox"
Tex1.Location = New System.Drawing.Point(12, 119)
Tex1.Size = TextBox1.Size
Tex1.TabIndex = 4
Tex2 = New Windows.Forms.TextBox
Tex2.Name = "TextBox"
Tex2.Location = New System.Drawing.Point(110, 119)
Tex2.Size = TextBox2.Size
Tex2.TabIndex = 5
Me.Controls.Add(Tex1)
Me.Controls.Add(Tex2)
i want to add the new textbox with clicking the picture box, like this
Click Here for Picture
but when i click the "add Picture Box" the textbox not appear
please, anyone help me ?
If you want to have the ability to add textboxes to your form then this is what you should do. First you will need to identify the button that you are going to use for this insertion event. I would assume the green plus symbol.
Then I would create a mouse event action like this:
Public Sub Mouse_Click(sender As Object, e As EventArgs) Handles MyButton.Click
' Some action...
End Sub
From there you will be able to insert your code into the click event like this:
Public Sub Mouse_Click(sender As Object, e As EventArgs) Handles MyButton.Click
Dim Tex1 As TextBox = Nothing
Dim Tex2 As TextBox = Nothing
Tex1 = New Windows.Forms.TextBox
Tex1.Name = "TextBox"
Tex1.Location = New System.Drawing.Point(12, 119)
Tex1.Size = TextBox1.Size
Tex1.TabIndex = 4
Tex2 = New Windows.Forms.TextBox
Tex2.Name = "TextBox"
Tex2.Location = New System.Drawing.Point(110, 119)
Tex2.Size = TextBox2.Size
Tex2.TabIndex = 5
Me.Controls.Add(Tex1)
Me.Controls.Add(Tex2)
End Sub
Now there is still a big issue with this code, the location of the textboxes. The reason this is an issue is because they are static, meaning they will always appear in the same spot so, one solution is to declare a global Point() to maintain the location of the newest textbox like this:
Dim tbLocation1 As Point = New Point(12, 199)
Dim tbLocation2 As Point = New Point(110, 199)
From there all you would then need to do is have some sort of margin amount that you want to move the textboxes by like this:
Dim marginAmt As Int32 = 30
Now that all of the pieces are present lets put it together:
Dim tbLocation1 As Point = New Point(12, 199)
Dim tbLocation2 As Point = New Point(110, 199)
Dim marginAmt As Int32 = 30
Public Sub Mouse_Click(sender As Object, e As EventArgs) Handles MyButton.Click
Dim Tex1 As TextBox = New Windows.Forms.TextBox
Dim Tex2 As TextBox = New Windows.Forms.TextBox
' Modifies Tex1
Tex1.Name = "TextBox"
Tex1.Location = tbLocation1
Tex1.Size = TextBox1.Size
Tex1.TabIndex = 4
' Modifies Tex2
Tex2.Name = "TextBox"
Tex2.Location = tbLocation2
Tex2.Size = TextBox2.Size
Tex2.TabIndex = 5
' Updates form
Me.Controls.Add(Tex1)
Me.Controls.Add(Tex2)
' Updates the point locations
tbLocation1 = New Point(tbLocation1.X, tbLocation1.Y + marginAmt)
tbLocation2 = New Point(tbLocation2.X, tbLocation2.Y + marginAmt)
End Sub
Now you just need to connect this event action to the button that you desire.

Trying to add UserControl to a TabPage inside of another TabPage get NullReferenceException

I have an UserControl and wish to add it to a TabPage Inside another TabPage but get NullReferenceException instead.
My code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyControl As New TimerPanel
Dim Ubicacion As Point
Ubicacion.X = 274
Ubicacion.Y = 100
With MyControl
.Name = "Timer0"
.NombreTimerTxt.Text = "Timer GPS"
.TimerBox.Text = "Timer 00"
.Parent = Me '.TabControl3.TabPages("Timers")
.Location = Ubicacion
.Visible = True
End With
Me.TabControl3.TabPages("Timers").Controls.Add(MyControl) 'Error here
'Me.TabControl1.TabPages("Timers").Controls("Timer0").Location = Ubicacion
End Sub
The IDE say that I must declare it using the word "New", but I already did it on the first code line.
Another thing, If I iterate this code changing the name and coordinates I will get independent controls or when I change one all do the same?
My form looks like this.
Thanks to LarsTech I solve the problem and add several UserControls to my TabPage using the following code
Dim X As Integer = 4
Dim Y As Integer = 0
For XTimer As Integer = 0 To 15
Dim MyControl As New TimerPanel
Dim Ubicacion As Point
Ubicacion.X = X
Ubicacion.Y = Y
With MyControl
.Name = "Timer" & XTimer.ToString
.NombreTimerTxt.Text = "Timer GPS"
.TimerBox.Text = "Timer " & XTimer.ToString
.Parent = Me
.Location = Ubicacion
.Visible = True
End With
TimersTab.Controls.Add(MyControl)
Y += 51
If XTimer = 9 Then 'Start column 2
X = 344
Y = 0
End If
Next
I hope someone finds this useful; bye.

Scrolling text in form title bar

I have written a simple code to scroll the text in the title bar of the form. It is working fine till the length of the text reach 159. After that the text cuts of in the title bar . It does not reach the end of the title bar rather cuts off in the middle of the title bar. Why does this happen?
tempheader is a variable that stores the me.text value at form load.
This is the code in the timer tick event with an interval of 100
Me.Text = " " & Me.Text
If Len(Me.Text) = 159 Then Me.Text = tempheader
Try this ..
Dim g As Graphics = Me.CreateGraphics()
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static sPace As String
sPace &= " "
Me.Text = sPace & Me.Text
If g.MeasureString(Me.Text, Me.Font).Width >= Me.Width Then
Me.Text = tempheader
sPace = ""
End If
End Sub
Lol I know this is an old post but I came across it whilst looking for something else anyway I just use a custom titlebar for scrolling text. Just create an empty form, doubleclick it delete all of the code and add the code from below. Go back and delete the form from the project and save it as a dll. You just need to import it back and add it to your toolbar and you can use it in any projects.
Imports System.Drawing
Public Class CustomTitlebar
Inherits Windows.Forms.Panel
Public Sub ColourTitleText(ByRef panelBG As Color, ByRef txtBG As Color, ByRef txtFC As Color)
Dim textbox1 As New Windows.Forms.TextBox
Dim Psize As New Point(26, 200)
Me.Size = New Point(26, 200)
Me.BackColor = panelBG
Me.BorderStyle = Windows.Forms.BorderStyle.None
Me.Dock = Windows.Forms.DockStyle.Top
Me.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
textbox1.Name = "Textbox1"
textbox1.BackColor = txtBG
If Not txtFC = Nothing Then
textbox1.ForeColor = txtFC
End If
textbox1.BorderStyle = Windows.Forms.BorderStyle.None
textbox1.Size = New Size(Psize.X - 4, 20)
textbox1.Location = New Point(3, 3)
textbox1.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
textbox1.Multiline = False
textbox1.Text = "Coded by tHE_alCHMist 2010"
Me.Controls.Add(textbox1)
End Sub
End Class
Put this in a timer "CustomTitlebar1.Text = MarqueeLeft(CustomTitlebar1.Text)"
and then put this function somewhere
Public Function MarqueeLeft(ByVal Text As String)
Dim Str1 As String = Text.Remove(0, 1)
Dim Str2 As String = Text(0)
Return Str1 & Str2
End Function
Finally remember to dock it with the top of the form and I hope someone finds this code useful.