[RESOLVED] Error With Input Dialog
All variables are defined.
Code:
static void GetUserInput(string Text)
{
FormInput IForm = new FormInput();
IForm.LabelQuestion.Text = Text;
IForm.ButtonAccept.Click += new EventHandler(ButtonAccept_Click);
}
static void ButtonAccept_Click(object sender, EventArgs e)
{
Button B = (Button)sender;
FormInput F = (FormInput)B.FindForm();
Input = F.TextBoxAnswer.Text;
F.Close();
F.Dispose();
}
Gives me this. It's in a static class.
Code:
An object reference is required for the non-static field, method, or property 'W4MAdvancedTweakLoaderB2.Program.Input'
Do you know why it's giving me this error?
Re: Error With Input Dialog
You are trying to access a non-static object "Input" from a static method. For obvious reasons that cannot work because the static method can be called before the non-static object exists. There is no reason for those methods to be static anyway, so just make it an instance method.
Re: Error With Input Dialog
Silly me, I fixed it, "Input" was not static.
Also, when it pops up, even if TopMost is set to true, it will not be above like an actual dialog. How do I fix this?
Re: Error With Input Dialog
The structure of your code seems a bit complicated, maybe we can help organize it a bit better. Can you tell me what class the methods GetUserInput and ButtonAccept_Click are from? Are they part of another form class?