-
October 16th, 2009, 02:39 PM
#1
[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?
-
October 16th, 2009, 03:03 PM
#2
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.
-
October 17th, 2009, 03:59 PM
#3
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?
Last edited by code?; October 17th, 2009 at 04:16 PM.
-
October 17th, 2009, 04:46 PM
#4
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|