Listview problem

  • Thread starter Thread starter Donald Smith
  • Start date Start date
D

Donald Smith

Hey,

I need help with my listview control. Here's my code:

Dim frm As New Form2()

Dim lvItem As New ListViewItem

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")

StatusBar.Panels(0).Text = "Not Connected: Error"



lvItem = frm.lvErrorLog.Items.Add(Date.Now)

lvItem.SubItems.Add(ex.Message)

End Try

There is a "Try" command, I just didn't show it. Here's my problem: I'm trying to add an item to a listview from one form to another. Like this, Form1 gets the error, and tells form2 to place the error in its listview.

Thanks.
 
Hi,

Try something like this.

Dim frm As New Form2

frm.Show()

Try

Dim x, y, z As Integer

x = 10

y = 0

z = x / y

Catch ex As Exception

Dim lvi As New ListViewItem(Now.ToShortDateString)

lvi.SubItems.Add(ex.ToString)

frm.ListView1.Items.Add(lvi)

End Try



Ken

Hey,

I need help with my listview control. Here's my code:

Dim frm As New Form2()

Dim lvItem As New ListViewItem

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")

StatusBar.Panels(0).Text = "Not Connected: Error"



lvItem = frm.lvErrorLog.Items.Add(Date.Now)

lvItem.SubItems.Add(ex.Message)

End Try

There is a "Try" command, I just didn't show it. Here's my problem: I'm trying to add an item to a listview from one form to another. Like this, Form1 gets the error, and tells form2 to place the error in its listview.

Thanks.
 
Back
Top