Hi
See if this stand alone example helps.
' Blank FORM1
Option Strict On
Option Explicit On
Public Class Form1
Dim lab As New Label
Dim dgv As New DataGridView
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With dgv
.Location = New Point(130, 40)
.Width = 100
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
.Columns.Add("Column1", "Column1")
With .Columns("Column1")
.DefaultCellStyle.Format = "0.00 Euro"
.Width = 65
End With
.RowHeadersVisible = False
.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
For i As Integer = 11 To 15
.Rows.Add(i / 3)
Next
End With
' ==========================
' this code block is ONLY for
' this example - you have your
' controls already on the Form
Dim y As Integer = 40
For i As Integer = 1 To 6
Dim tb As New TextBox
With tb
.Location = New Point(20, y)
.Width = 100
.TextAlign = HorizontalAlignment.Right
Controls.Add(tb)
AddHandler tb.TextChanged, AddressOf TextBox_TextChanged
AddHandler tb.Validated, AddressOf TextBox_Validated
y += tb.Height + 4
End With
Next
With lab
.Location = New Point(20, 5)
.AutoSize = True
.Font = New Font(.Font.FontFamily, 20)
End With
Controls.AddRange({lab, dgv})
' ==========================
End Sub
' you could probably use thse two
' Subs as a possible answer to
' your question
Private Sub TextBox_TextChanged(sender As Object, e As EventArgs)
Dim total As Double = 0.0
For Each c As Control In Controls
If c.GetType = GetType(TextBox) Then
total += GetDouble(c.Text)
End If
Next
lab.Text = total.ToString("0.00")
End Sub
Private Sub TextBox_Validated(sender As Object, e As EventArgs)
Dim tb As TextBox = DirectCast(sender, TextBox)
If Not tb.Text.EndsWith("Euro") Then tb.Text &= " Euro"
dgv.Rows.Add(GetDouble(tb.Text))
End Sub
Function GetDouble(s As String) As Double
If s.EndsWith(" Euro") Then s = s.Substring(0, s.Length - 5)
Dim v As Double = 0.0
If Double.TryParse(s, v) Then Return v
Return 0.0
End Function
End Class
need, and also need to be aligned to the right side of the textbox. Same is need it with DataGridView cells in entire column. Thank you.

