I want to select the form of my application to edit settings of a textbox in it. I used Form.ActiveForm
for this. This works great while the Form is in foreground, but when it's not selected, this doesn't work anymore. Is there a way to get the applications current form, even when it is in background?
EDIT: Here's some code:
var form = Form.ActiveForm as MainForm;
if (form != null)
{
form.txtChatOutput.Text += p.Data[0] + "\r\n";
}
EDIT 2:
I found a easy solution. Declare a Variable Form myForm; in the class and in your form's Shown event, set it to Form.ActiveForm.
public partial class Form1 : Form
{
Form myForm;
....
private void Form1_Shown(object sender, EventArgs e)
{
myForm = Form.ActiveForm;
}
}
You can then access your form using myForm, even if it's not selected anymore.