call listview item from parent form
I create new form(child) named searchuser.I have this listview item in the main menu form.The problem is that when I do the coding in the searchuser, the system did not understand maybe because the parent- child call function. The coding in the searchuser form look like this:
Private Sub btnsearchuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearchuser.Click
If Me.txtuname.Text = "" Then
MessageBox.Show("Please enter username .")
Exit Sub
End If
Dim a As New frmMainMenu
a.lvwReport.View = View.Details
a.lvwReport.GridLines = True
a.lvwReport.CheckBoxes = True
a.lvwReport.FullRowSelect = True
If a.txtExplorer.Text = "User Profile" Then
a.lvwReport.Columns.Add("User Id", 100, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("Full Name", 100, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("IC", 100, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("Email", 100, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("ACL", 100, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("Phone Number", 100, HorizontalAlignment.Left)
Dim GetUser As String = "SELECT * FROM USER WHERE USERSUID = '" & Me.txtuname.Text & "'"
Dim conn As New OdbcConnection(ConnStr)
Dim cmd As New OdbcCommand(GetUser, conn)
Dim drReader As OdbcDataReader = cmd.ExecuteReader
conn.Open()
drReader = cmd.ExecuteReader()
Dim str(6) As String
Dim itm As ListViewItem
Do While drReader.Read
str(0) = drReader("usersuid").ToString
str(1) = drReader("users_name").ToString
str(2) = drReader("users_ic").ToString
str(3) = drReader("users_email").ToString
str(4) = drReader("users_acl").ToString
str(5) = drReader("users_phone").ToString
itm = New ListViewItem(str)
a.lvwReport.Items.Add(itm)
Loop
conn.Close()
Else
a.lvwReport.Columns.Add("ACL Definition", 100, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("ACL Definition Description", 150, HorizontalAlignment.Left)
a.lvwReport.Columns.Add("ACL List", 100, HorizontalAlignment.Left)
Dim GetACL As String = "SELECT * FROM acldef where acldef_group = '" & Me.txtuname.Text & "'"
Dim conn As New OdbcConnection(ConnStr)
Dim drReader As OdbcDataReader
Dim cmd As New OdbcCommand(GetACL, conn)
conn.Open()
drReader = cmd.ExecuteReader()
Dim str(3) As String
Dim itm As ListViewItem
Do While drReader.Read
str(0) = drReader("acldef_group").ToString
str(1) = drReader("acldef_groupdesc").ToString
str(2) = drReader("acldef_acl").ToString
itm = New ListViewItem(str)
a.lvwReport.Items.Add(itm)
Loop
conn.Close()
cmd.ExecuteReader.Close()
End If
End Sub
Private Sub searchuser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New frmMainMenu
a.lvwReport.Visible = False
a.lvwReport.Clear()
a.lvwReport.Refresh()
a.lvwReport.Columns.Clear()
End Sub