For each Controls Datafields text datagrid




Private Sub InserisciText()
Dim targetControl As Object
For Each targetControl In Me.Controls

If TypeOf (targetControl) Is System.Windows.Forms.TextBox Then
' TextBox

targetControl.databindings.add("text", BindSrc, targetControl.tag)


ElseIf TypeOf (targetControl) Is System.Windows.Forms.Label Then
' Label


ElseIf TypeOf (targetControl) Is System.Windows.Forms.DataGridView And targetControl.name = "ClientiDataGridView" Then
' datagridview

Try
' Set up the DataGridView.

With targetControl
' Automatically generate the DataGridView columns.

.AutoGenerateColumns = True

' Set up the data source.

.DataSource = BindSrc

' Automatically resize the visible rows.

.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders

' Set the DataGridView control's border.

.BorderStyle = BorderStyle.Fixed3D

' Put the cells in edit mode when user enters them.

.EditMode = DataGridViewEditMode.EditOnEnter
End With
Catch ex As Exception
MessageBox.Show("KO!!! C'e' UN CAZZO DI ERRORE NELLA FORMAZIONE DI QUESTO 'CAZZO' DI DATAGRIDVIEW ", _
"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
System.Threading.Thread.CurrentThread.Abort()
End Try
End If

Next















( foreachcontrolsdatafieldstextdatagrid.html )- by Paolo Puglisi - Modifica del 17/12/2023