I’m trying to add some text to a listBox in a form, from another form, but I get red underlines in the code that should add to the listBox. Isn’t it possible to pass data to a form in a class from another class that I’m trying to do? I’m using VisualStudio 2010
I have this code I’m using in the MainForm class:
// Local object of SearchResultForm
SearchResultForm frmSearchResult = new SearchResultForm();
frmSearchResult.Show();
frmSearchResult.lstSearchResult.Items.Add("Test");
Error message: inaccessible due to its protected level
A control is usually a variable, so try this for Winforms:
WPF: