C# Your First Windows Forms Application

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi in this video I'm going to take you through a tutorial to create your first Windows application in c-sharp so we're using Visual Studio 2019 and looking at the Microsoft tutorial page our goal for this video is to get to the end of this section called create a Windows forms app so let's see what its gonna look like let's scroll down aways you're gonna see we're gonna have a windows form that looks like this we're gonna put a button on it and then we're going to put a message on the screen that says hello world when we click the button this message will change so a pretty simple app but it's a great way to get started with Visual Studio so I'm going to switch back into Visual Studio you can see that I've got a program open and this was called calculator app so I'm going to move on to the next step I'm gonna go to file choose new project and let's choose a Windows app so at this time instead of console I'm going to choose desktop and let's see what my choices are so I want something called a Windows forms app with the.net framework using the c-sharp language so in a previous video I said there's lots of other options you could use one called WPF another one called Universal but we're looking for this guy here called the windows forms app with dotnet c-sharp okay get all that and you got yourself a starting point now we've got ourselves the name here so windows forms an app I'm gonna call this thing hello world and I'm gonna call it wind forms you can name it anything you want and just as you can see I'm not using spaces I'm just kind of habit of doing that with computer things they don't always like spaces you can check all the rest of the stuff here if you need to and let's create alright so the application is up and running now right away you're going to notice a few things different than the previous program so first of all the toolbox look at all these nice little toys we have to play with the project and the solution has a program and now this thing called form 1 so let's just click the green button and see what comes up here so we should see ourselves form one alright so you can see our program is up and running we have form 1 we can move it around we can resize it we can maximize it we can restore it and minimize and just everything you can do with a program except for actually anything useful so I'm going to close it now we want to put some things on it so you can experiment just by dragging things from the toolbox onto the form and then see what they look like when you run it so let's try a button now let's put on two buttons and let's put in a checkbox and let's try a ListView and let's see what else there is there's all kinds of things a radio button alright so we got all these tools and toys to play with what do they look like let's run the program alright so here's the program it doesn't look very great so the list box has nothing in it you can check the radio button you can check the check box you can click the buttons that are actually probably too small the text is hiding but the the ease of use of WinForms is so obvious here you just drag things on and they appear now you have to do the programming of course and that's what we're gonna do next so let's let's delete a bunch of stuff here I'm gonna just select this item don't double click it just delete it by clicking once and then pressing the delete on your keyboard okay so it doesn't want to delete I'm gonna right-click and choose delete there we go let's try the button apparently I have to do right-click and delete my macintosh keyboard doesn't translate like I expected it okay so I'm deleting and let's now resize this button so let's put in the center of the screen and then let's change the text right now it says button one so the things that you can change on buttons are called properties so if I scroll over to the right side here you can see I've got all kinds of things that I can change so I'm looking for the property called texts and I'm gonna put in the word hello okay I'm gonna say click me you can put anything you want there if you want to experiment you can try the different colors so if you want a different different scheme you can change the text color you can change fonts all kinds of things that can be changed here so just up to your imagination okay so experiment with all the different types here now I'm going to change the name of this guy so let's go and find the property called name so here it is design is the section name is called button one now it's common that we would change these names I'm gonna put BTN underscore hello now BTN obviously stands for button and when you start programming it's a good idea to use prefixes like BTN for button if I had a label on the screen I would call it lvl a radio button I would probably put Rd R or something so you get to make up your own schema but this is pretty standard stuff here to change the name - BTN underscore hello now I'm gonna change something on the screen so I'm going to need something to change I'm gonna put a label out here so let's see the label comes out and the text is label one so now the label 1 is out and the name of the label it's like I said before I'm gonna use a prefix LBL and I'm gonna call it hello message so that seems to make sense to me I'm gonna press ENTER now the text itself let's go and find the text property is there a text property there it is so for right now I'm gonna set it to nothing I'm gonna just press ENTER and it'll clear it out so the label is an empty string now I want to modify the label let's double click on the button now and you see a new screen appear it says form 1 dot C s if you want to switch back to the designer you can switch back in these tabs here you can also right-click on the form 1 and you can choose view code and that will bring into the code you can right click on here and choose view designer and it'll take you here so I'm going to double click here again and now I have a function let's look at here this is a function that is now going to be programmed so the rest of the stuff you can ignore for now all of our action is going to happen in here so this says in this method called BTN hello click that means whenever this button is clicked what we're gonna do is change the property of something so I'm gonna change the property of my label so I'm gonna type in the word LBL and the help comes across here it says hey I noticed you have lvl help hello message so probably what you want right yes it is now I'm going to type in a period after that and set the word for text te XT I can just press ENTER and I can put in a string so I'm gonna put in two quotation marks and something inside there then I'm gonna just say nice to meet you and then I'm gonna run the program alright here's the program it's up and running I click on hello and now I get it nice to meet you okay that's cool I'm gonna do something else I'm gonna put in another button and just give you some ideas on what to experiment with so here I'm going back to design I'm gonna drag another button on the screen and I'm going to name him something else so for the text I'm gonna say change color and for the name of the button I'm going to give this thing a different name so let's go down to here instead of bTW it's called BTN one change color and I'm going to double click here and you can see now I have a second routine it says this was button hello click now this is button change color click and I'm gonna literally change the color of the label so let's do label and let's see if we can change the is there a color there is something called for color let's show how to try that for color equals and now I need some value I think I think we can just type in the word color dot and let's see there are different previews so let's try red now okay so that might work let's see what happens okay so the program is up and running I'm gonna click hello and then I'm gonna try change color and sure enough it changed to red now I can't change it back because I've only programmed one way I need another button or some other function to change the color to something else but that's the neat part about programming is that you are the superhero you get to program the robot to do anything you want so experiment is all you want here and work with labels and colors and properties you can change the font size you can change the text itself so the limitation is you and your imagination so this is probably a good place to stop I'm looking here at what they showed you in the tutorial a really simple hello world app but yeah take it from there and see what you can learn so that is your second application your first one with a graphical user interface you
Info
Channel: shad sluiter
Views: 43,497
Rating: 4.9563317 out of 5
Keywords: windows forms, visual studio, c# programming, learn c#, c# tutorial, c sharp, c# programming language, desktop application, c# tutorial for beginners, c# (programming language), .net framework, how to, visual studio 2019 tutorial, visual studio 2019, windows forms app, windows forms tutorial c#, c# as first programming language, windows forms application c# tutorial, how to learn c# programming language, how to understand c# programming language
Id: n5WneLo6vOY
Channel Id: undefined
Length: 9min 38sec (578 seconds)
Published: Sun May 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.