This is the first time I encounter this error in a textbox
private static void infoGather_keydown(object sender,KeyEventArgs e)
if (e.KeyCode == Keys.Enter)
if (username == null)
username = infoGather.Text;
password = infoGather.Text;
if (username == "admin" && password == "admin")
infoGatheran is a member of an instance of the class, and is not
static. Therefore you can't access it though a static function.
If you think about it it doesn't make sense - A static method belongs to the class and not a specific instance, therefore when you try to access a member of an instance - of which instance will it be?
To solve the specific error - is there any real reason to have this method
static? If not just remove the
static from the signature.