Something like this?
Private Sub btnAdd_Click(By Val sender As Object, ByVal e As
System.EventArg s) Handles btnAdd.Click
Dim sIP As IPAddress
If txtIPAddress.Te xt = "" Then Exit Sub
Try
sIP = IPAddress.Parse (txtIPAddress.T ext)
Try
For Each lstviewitem As ListViewItem In lstIPAddresses. Items
If lstviewitem.Tex t = txtIPAddress.Te xt Then
MessageBox.Show ("IP Address is already in list.",
"Invalid Entry", MessageBoxButto ns.OK, MessageBoxIcon. Information)
Exit Sub
End If
Next
Dim item1 As New ListViewItem(tx tIPAddress.Text )
item1.SubItems. Add("Not yet tested")
lstIPAddresses. Items.Add(item1 )
txtIPAddress.Cl ear()
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
Catch ex As Exception
MessageBox.Show ("Not a valid IP Address.", "Invalid Entry",
MessageBoxButto ns.OK, MessageBoxIcon. Warning)
txtIPAddress.Cl ear()
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********@ade lphia.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.It ems(10).SubItem s.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.It ems
...
Next lvi
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>