 Hey everybody, this is Brian. Welcome to the 24th C-Sharp tutorial. Today we're going to be discussing the radio button. Let's see if I can find it here. Just a radio button. Let's just throw a couple of these on here. And you notice how it names a radio button 1, 2, and 3? Now, what does a radio button do? Well, you notice how one's kind of dotted. It's not really a check, it's more of a dot. And when you select another one, it unchecks and checks the other one. So that's how you select an option, like what's your favorite color, red, green, blue? Something like that. So let's actually set the text of these. And I want to show you what happens. Actually, let me grab a group box here. It's expand containers and you see a group box? Just drag and drop that out there. And I want to show you the base functionality of a group box in regards to radio buttons. So let's just control C, select group box, control V. And now we've got two sets of radio buttons. Now, how do I know there are two sets? They're in different containers. When you select this group box, this acts as a container, whereas the form is a container also. So let's actually set this to center screen. That way we know where it's going to show up. Run this. You notice how we have two different sets of radio buttons. So you could say, what's your favorite color? What's your secondary favorite color? Now, how do you actually get the value here? How do you know what's what? Let's throw a button out here and let's find out. So we're just going to say, and you notice how there's the radio buttons, radio button one. Checked. Very simple. Very easy. So you could say, okay, if then statements. This is probably the easiest way to do it. And let's just make a string here. So string as color and we'll say, radio button one text. And that's all we're really going to do here. Now, I know some of you out there, some of you old gurus are probably screaming Brian. Brian, there's easier ways. This is a beginner's tutorial, guys. So let's just keep it from a beginner's level. So that's one way of doing it. Save it. And let's actually throw a message box up here at five and run. So let's say my favorite color is blue, click the button and we did a boo boo. As color equal radio. Yes, radio three dot text. That's why. So let's try that again blue and there we go. My favorite color is blue. Let's try green. Sure enough green. So let's find a more advanced yet simpler way of doing this here. Let's throw another button out here. Let's throw it in here. And here's our button to double click that. Now, what I want to do is make a function. We'll call this private void. Get color. And we want a radio button. And just call this RDO button as a parameter. So what we're going to do here is we're going to say, okay, send this radio button as the parameter to this function. And we're going to encapsulate this code here. So we're going to say, if RDO button, the radio button, checked, then we're just going to just pop up the message box here just for sake of argument here. Then we will just simply say, get color, radio button four. And we will just do this a couple of times here. And this is a more advanced option. The most advanced option, which we won't get into today because it's beyond the scope of what we learned so far, is using what's called reflection where you would query all the controls in the form and then see if it's a radio button and then for each radio button do something. But this is a mid-range version of it. So let's run this and we'll say green. Notice how this is blue. This is green. So that in a nutshell is the beginner's guide to the radio button. This is Brian. I hope you found this tutorial educational and entertaining. And thanks for watching.