What I'm trying to do is a search box, exactly the same as in VS or Notepad ++, where both windows are active (because FindBox is displayed with Show ShowValog), and when you click find on FindBox, the parent searches. Here is an example:
class MainForm : Form
{
public void FindNext(string find)
{
}
public void OpenFindWindow()
{
FindBox find = new FindBox();
find.customParent = this;
find.Show();
}
}
class FindBox : Form
{
public customParent;
public void FindButtonPressed()
{
((MainForm)customParent).FindNext(textBox1.text);
}
}
But it seems strange to me that I need to manually set this new "customParent" field. What is the official way to do something like this?
source
share