Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Adding a row in the listview from another form.

Hi,

I am using C# and i programm in VS2010.

I have a mainform with a listview called lvNotes on it, and a second form called stickynotes.

After closing the stickynotes form I want to create a row in the listview on the mainform.
This is what I have:

        private void StickyNotes_FormClosed(object sender, FormClosedEventArgs e)
         {
                ListViewItem myItem = new ListViewItem(lblTitle.Text, 0);
                myItem = lvNotes.Items.Add(myItem); <=====================
                myItem.SubItems.Add(rtbContent.Text);
                myItem.SubItems.Add(lblCreation.Text);
                myItem.Selected = true;
            }

Open in new window


But I don't know how to create a row in the listview from the StickyNotes form!

I get error:

The name 'lvNotes' does not exist in the current context

Who can help me?

Peter Kiers
ASKER CERTIFIED SOLUTION
Avatar of Anuroopsundd
Anuroopsundd
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial