This is a first so my apologies for any mistakes or further confusion.
First of all I'm creating a small game on c# windows form where user inputs name, date of birth, and chooses avatar I used textbook-name, combobox-date of birth, and lastly radio buttons as images-for user to control as picture box in my other form2.
I figured out you use string for name input but:
I was confused on the data for combobox input choice to text in the bottom right of my other form(should I use string for combobox input?)+name
As well as radibutton choice to picture box that user gets to control in form2 since I don't want it as text so I didn't use string.
It would be very helpful for any answers or notes. Thank you and sorry for any confusion.
If the user is entering a date of birth then the obvious data type for the value is
DateTime. You might also be able to useDateOnlyin newer versions but, even if you do, there's every chance that you'll need to convert toDateTimeat some point because one has been around since the inception of .NET and one is very new.If you're using WinForms to enter a date then the obvious choice of control is
DateTimePicker, notComboBox. The user can then enter the whole date in one place and you get aDateTimevalue from theValueproperty.If you insist on using
ComboBoxesthen I assume that you have three - one each for day, month and year. If you populate the drop-down lists in the designer then you'll be addingstrings, so you will then need to convert theTextorSelectedItemto anintfirst, then create aDateTimefrom those threeintvalues.If you populate the drop-downs in code instead, you can actually add
intvalues in the first place and there will be no conversion required, but you'd still need to cast theSelectedItemfrom typeobject.Note that a
DateTimePickerwill ensure that only a valid date is selected. If you useComboBoxes, you'll have to ensure that the user doesn't select an invalid day for the selected month, e.g. February 30.