NP, I have added a check to verify that the listitem the user is trying to add to the list is not already in the listview, but now the item does not add at all. Maybe this is another VB6 vs. .NET thing?
Code:Private Sub btnAddSurgeProcedure(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddSurgProcedure.Click Dim lvItem As New ListViewItem, strSurgProcedure As String, strSurgPerformed As String, strSurgName As String, strSurgPhone As String, strSurgFacility As String, strSurgPostOp As String, i As Integer 'remove leading and trailing spaces from the entries and store as a variable strSurgProcedure = Trim(txtSurgProcedure.Text) strSurgPerformed = Trim(dtpSurgPerformed.Text) strSurgName = Trim(txtSurgName.Text) strSurgPhone = Trim(txtSurgPhone.Text) strSurgFacility = Trim(txtSurgFacility.Text) strSurgPostOp = Trim(txtSurgPostOp.Text) 'set lvitem to the value of the SurgProcedure string lvItem.Text = (strSurgProcedure) 'Set the value of the lvitem subitems With lvItem .SubItems.Add(strSurgPerformed) .SubItems.Add(strSurgName) .SubItems.Add(strSurgPhone) .SubItems.Add(strSurgFacility) .SubItems.Add(strSurgPostOp) End With 'check to see if the procedure already exists in the listview For i = 1 To lvSurgProcedures.Items.Count If strSurgProcedure = lvSurgProcedures.Items(i).Text Then ' MessageBox.Show("The Surgical Prodcedure you are trying to add is already in the list") Else 'add the lvitem to the listview lvSurgProcedures.Items.Add(lvItem) End If Next




Reply With Quote