Something like this?
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim sIP As IPAddress
If txtIPAddress.Text = "" Then Exit Sub
Try
sIP = IPAddress.Parse(txtIPAddress.Text)
Try
For Each lstviewitem As ListViewItem In lstIPAddresses.Items
If lstviewitem.Text = txtIPAddress.Text Then
MessageBox.Show("IP Address is already in list.",
"Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
Next
Dim item1 As New ListViewItem(txtIPAddress.Text)
item1.SubItems.Add("Not yet tested")
lstIPAddresses.Items.Add(item1)
txtIPAddress.Clear()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Catch ex As Exception
MessageBox.Show("Not a valid IP Address.", "Invalid Entry",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtIPAddress.Clear()
End Try
End Sub
It works, but I don't know if it's the best way of doing it....
-J
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2m************@uni-berlin.de...
* "OpticTygre" <op********@adelphia.net> scripsit: I am unfamiliar with the listview control, and I need a bit of help. My
listview control has 2 columns. I'm trying to populate the first column
with text in a textbox when a user clicks the "add" button, and also
populate the second column with text depending on what went in the first
column. I have a few questions, though. I can add the first column
text simply with listview.items.add, but how do I add text to the second
column?
\\\
Me.ListView1.Items(10).SubItems.Add("Foo")
///
Also, how would I cycle through the items in the listview control (first
column) to make sure I don't add duplicate entries? Thanks for any
help.
\\\
Dim lvi As ListViewItem
For Each lvi In Me.ListView1.Items
...
Next lvi
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>