Torna al Thread

Private Sub ListView1_ItemCheck(sender As System.Object, e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck 'recupere l'indice dell'insieme che ha cambiato stato (Checked o Unchecked) Dim id As ListViewItem = Me.ListView1.Items(e.Index) 'controlli se lo stato del nuovo valore che prenderà è Checked If e.NewValue = CheckState.Checked Then '** 'serve se vuoi riportare allo stato precedente in caso 'di errore di formattazione nella seconda InputBox 'Dim testoPrecedente As String = id.SubItems(4).Text '** Try Dim text1 As String = InputBox("DOVUTO", "Inserisci Importo mensile", 0) If Not String.IsNullOrEmpty(text1) Then Dim text2 As String = InputBox("PERCEPITO", "Inserisci Importo mensile", 0) If Not String.IsNullOrEmpty(text2) Then id.SubItems(4).Text = Format(CType(text1, Decimal), "###,##0.00") id.SubItems(5).Text = Format(CType(text2, Decimal), "###,##0.00") Else e.NewValue = CheckState.Unchecked End If Else e.NewValue = CheckState.Unchecked End If 'se devi ancora impostare impostare altro, tipo quelli sotto, ti conviene inserirli dopo la scrittura 'dei subItems in modo che se c'è un problema (tipo annulla) quelle voci non vengono modificate 'm_ParametroIDCompetenza = id.Text 'm_ParametroTipologia = id.SubItems(2).Text Catch ex As Exception '** 'in caso di errore sulla formattazione della seconda InputBox 'puoi rimettere il valore pèrecedente a id.SubItems(4).Text (se vuoi) 'id.SubItems(4).Text = testoPrecedente '** MessageBox.Show("Inserire solo numeri") 'riporti il CheckBox a false e.NewValue = CheckState.Unchecked End Try End If End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5