I'm currently making a simple C# game for a college assignment, wondering if it's possible to have radio or checkbox (or something similar) inputs upon loading, in an external window. I'm currently using this to get a username:
public Form1()
{
InitializeComponent();
Initialize();
GlobalVar.Username = Microsoft.VisualBasic.Interaction.InputBox("Welcome to EasiGame, Please enter your username.", "Welcome", "Player1", -1, -1);
label4.Text = GlobalVar.Username;
}
This references VB, and that works great, however could I include radio buttons or something in this box, or a separate box, to grab user input for a difficulty setting. Thanks in advance!
You would have implement your own form. Assuming you're using a recent version of Visual Studio:
Project
>Add Windows Form
.FormBorderStyle
property of the Form control toFixedDialog
to prevent the user from resizing the form.MinimizeBox
andMaximizeBox
properties to false.StartPosition
property toCenterScreen
orCenterParent
.OK
and set theDialogResult
property toOK
.Cancel
and set theDialogResult
property toCancel
.AcceptButton
property of the form to reference theOK
button.CancelButton
property of the form to reference theCancel
button.TextBox
and aRadioButton
orCheckBox
control to the form.F7
key to open the code view for the form.string
that returns theText
property of theTextBox
control.ShowDialog()
method. This will block the calling method until the user has clicked a button. TheShowDialog
method will return aDialogResult
, which can be used to determine which button was clicked.