Torna al Thread

Private Sub dgwComuni_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles dgwComuni.CellValidating If e.ColumnIndex > 0 And e.ColumnIndex < 4 Then With dgwComuni.Item(e.ColumnIndex, e.RowIndex) If String.IsNullOrEmpty(e.FormattedValue.ToString()) Then .ErrorText = "Il campo non dovrebbe essere lasciato vuoto" Else If e.ColumnIndex = 1 Then Dim lunghezza As Integer = Len(e.FormattedValue.ToString()) If lunghezza > 100 Then .ErrorText = "Il campo non dovrebbe superare i 100 caratteri" Else .ErrorText = Nothing End If Else If e.ColumnIndex = 3 Then Dim lunghezza As Integer = Len(e.FormattedValue.ToString()) If lunghezza > 2 Then .ErrorText = "Il campo non dovrebbe superare i 2 caratteri" Else .ErrorText = Nothing End If Else .ErrorText = Nothing End If End If End If End With End If End Sub '***********DGW COMUNI DATA ERROR***************** Private Sub dgwComuni_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgwComuni.DataError Dim Result As DialogResult Result = MessageBox.Show("Si è verificato un errore di compatibilità dei dati immessi." & _ Environment.NewLine & "Messaggio: " & e.Exception.Message & Environment.NewLine & _ "E' possibile che dei dati mancanti compromettano il database. Premere OK per modificare opportunamente " & _ "tali valori", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) If Result = Windows.Forms.DialogResult.OK Then e.Cancel = True dgwComuni.BeginEdit(True) End If End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5