I have a form with a listview and an edit button named Form1. When
the edit button is clicked, a dialog box containing some textboxes
should appear and the textboxes should be filled with data from the
currently selected listview item. The dialog form is called FormEdit.
How do I access the listview object on my main form the dialog form?
// The main form, in a file called Form1.cs... contains the listview
and the edit button
namespace WindowsApplication17
{
public partial class Form1 : Form
{
public Form1()
{
ListViewItem lvItem = new ListViewItem(textBoxLastName.Text, 0);
listView1.Items.Add(lvItem);
}
private void btnEditRecord_Click(object sender, EventArgs e)
{
FormEdit formEdit = new FormEdit();
formEdit.ShowDialog();
}
}
}
// The edit form, in a filed called Form2.cs
namespace WindowsApplication17
{
public partial class FormEdit : Form
{
public FormEdit()
{
InitializeComponent();
}
private void FormEdit_Load(object sender, EventArgs e)
{
// here is where I want to pull the data from the listview
on Form1 and populate the textboxes
// on this dialog with information from the main form
}
}
}
I can access the Form1 object by just typing it "Form1", but there is
no access to the listview (ie. Form1.listView)