 Hey everybody, this is Brian, and today we start our 20th C-Sharp tutorial, effectively what I call the good stuff. It's great to do a console application, but sometimes you need a little bit more like a Windows application. So that's what we're going to dive into today, and we're going to spend quite a bit of time on Windows apps, and then we're potentially going to do services, and then web pages, I know a lot of you want to do web apps. So we have our simple web, or I'm sorry, our simple Windows application. You see this as form one, and there's this little window, and when you click the close button, nothing happens. Why is that? Well, this is actually your window template. You see how you can kind of scale this around and do whatever you want, but none of the actual buttons and stuff work. Why is that? Well, it's because this is a canvas that you can drag and drop tools onto. Now if you click the solutions explorer, you'll see that, let me pin that up there, you've got form one, and that's what this is, is form one. If you expand that out, you see there is a form one dot designer and a form one dot res. The designer, if you click that, this is the actual source code behind that form, and you can see there's a lot of stuff in here that's already pre-generated for you. For example, initialized component, et cetera, et cetera, and Microsoft's done a fairly good job of kind of commenting what this stuff does. General rule of thumb, don't modify this. And then there's this res x. Now what is that? Well, this is a resource file, something you may have covered in other languages. Basically, a resource file allows you to put resources, images, strings, things of that nature in a file. Let's close that, and let's go tools over here, and let's pin that up. You see you have this huge, huge, huge assortment of controls, and we're going to go over a lot of these. And I have to apologize if you hear some thumping noise, and my cat is jumping around my desk like a lunatic. All right, so first thing we're going to do is we're going to put a button on here. You just click, drag, and drop. There's your button. You notice how it gets these little handles, and you can resize the button however you see fit. So let's just throw that kind of in the center here. You notice how it's off-center? Well, you have these positionals. So you can say, we want this, let's see here, centered that way, see if I can get this right. Center horizontally. There we go. Center vertically. There we are. Makes it easier to center things. Now to run, you just click this little start debugging, or you can press F5 on the keyboard. And let me move the window over here, and you see there's our beautiful window with our button that does absolutely nothing. So what we're going to do is we're going to make this button do something. I realize this is a very simple tutorial, but GUI programming may be new to some of you out there. If it's not, bear with me. We're going to ramp up these tutorials fairly quickly. All right, so select your button. You can tell it's selected because you've got these little handles around it. Just double-click it. You notice how it dumps you directly into the code view? Let's expand that. So we're in button one click. This is an event. Windows Form Programming is event-driven, meaning this is called when the button is click. That's an event handler. Notice how there's an object sender, everything in .NETS is object. So they're just saying whatever the sender was, and event args. What are event args? Well event args, or short for event arguments, it's just an argument sent with the event. And you can actually expand that and create your own event args. I actually do that quite a bit in my own programming. But like I said, this is a beginner's tutorial, so we're going to keep it very simple. All you need to understand at this point is when the user clicks that button, this event is called. And we can even say this is called when the button is clicked. My cat is looking at me like I have just lost my mind. Go away kitty. What we want to do is type messagebox.show, and we're just going to say hello world. The obligatory hello world application here. And let's run this, show our window here, click it, hello world. So that is our very first Windows Form application. Not a lot to it, mind you. One thing you should know in the solution explorer here, let me see if I can actually find it, view other windows, properties, windows, here we go. Everything has properties, and this is the properties window. So when you click your button, you see it has a bunch of properties. And when you click your form, it has a bunch of properties. See like the name even. So we can change the title here, see text form one, let's just call this my app. Notice how the title bar over here changed. Button one, the text, let's just say click me. Notice how it changed. See this little lightning bolt here? That's the events. And as you can see, the click event is linked to button one click, and if you just double click that, it takes you right to it. Pretty simple, pretty easy to understand. Notice how the properties for the code view are not displayed, because well code doesn't have a property, but the designer view does. And you can switch from events to properties just by clicking the buttons. You can group them by category, and you can sort alphabetical. I understand that because this window is so small, it's probably a little cluttered. Yours would probably look much better on your screen. So that is it, our very first GUI application in C-Sharp. And you can kind of stretch this out, modify it, do whatever you want. This is Brian. Thank you for watching. I hope you found this educational and entertaining.