public void NameTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { UserController activeController = UserControllerManager.GetActive(); if (activeController is ChooseButton) { ChooseButton button = (ChooseButton)activeController; if (!(button is null)) { button.Text = this.Text; } e.Handled = true; button.Refresh(); // Refresh print of button } else if (activeController is ToggleSwitch) { ToggleSwitch toggleSwitch = (ToggleSwitch)activeController; if (!(toggleSwitch is null)) { toggleSwitch.SwitchText = Text; } e.Handled = true; toggleSwitch.Refresh(); // Refresh print of button } } }