C# Speed Track - Lessons

 

What We are Going to Build

Everyone starts out with a “Hello World” application. We’ll look at that just for kicks but we’re going to build a practical, but simple, database application. Yes, you can do it. And doing it will introduce you to all sorts of things that are used when programming in C#.

Obviously We Need the Language

It’s free and we’ll get it from Microsoft. You can click on the button here or go back up to the overview page and choose “Getting the Software Free”. Either one. It’s the same video.

Gotta Have a Plan

Something needs to be down on paper (or on screen). Yes, you’re smart but when you start putting code to your design it’s easy to miss things. Even with a plan things get forgotten. A plan helps you self check what your are doing. And it allow you to add new things. The plan does not need to be perfect. In fact it shouldn’t be. It’s scrap paper to help you organize your thoughts.

You Use the IDE to Create your Project

This is probably the most intimidating thing you’ll deal with. Basically it’s your canvas. And it has tools on it. And properties. And all kinds of things most of which you won’t need to learn right now. So we’ll tiptoe past the irrelevant stuff and use what we need. And we’ll learn as we go.

Let’s Set Up the Form

Thanks to our plan we can set up our form. We need to do this before we do any coding as we’ll be using the names of our form objects in code. Sure, it’s possible that we’ve forgotten to place somethings on the form. But they can be added later. The important thing is that most of our stuff is here.

Time to Name the Components

Your components are already named by C#. But those names are not very helpful when it comes to Microsoft’s IntelliSense. by naming your components yourself you can group them. That way, when coding, you can just type in the first couple of letters and IntelliSense will make suggestions for you. Sort of like texting on your phone.

Code Form_Load

When the completed program is executed, the first thing that happens is all code in Form_Load executes first. This allows you to set up your form so it presents properly to the user.

Code the EXIT Button

Get the easy stuff out of the way first. Then we don’t need to deal with it later.

Code the ADD Button

This will give us a chance to learn a little bit about the ListBox. It’s a very useful tool that allows you to store a whole bunch of data in one place.

Code the CLEAR Button

This code will wipe all traces of any data we have entered or loaded. It essentially puts us back to square one when using our program.

Code the EDIT Button

Really this just sets up the Update and Cancel buttons. They do all the actual work.

Code the CANCEL Button

Oops! You didn’t mean to edit that record. Cancel allow you to get out without changing anything.

Code the UPDATE Button

This button commits the changes the user has made.

Code a Method to Minimize all that Button Flipping Code

One thing about programming, you do a lot of the same stuff over and over again. Methods allow you to create a small snippet of code once and then use it over and over again by calling it by name.

Code the SAVE Button

When you turn off that computer at the end of the day it’s nice to know that when you come back in the morning all your data is still there.

Code the LOAD Button

Of your in the morning you will need a way to bring that data back. The Load button fulfills that job nicely.

Code the DELETE Button

There are times when you want to remove data from your data collection. The Delete button allows you to specify a piece of data and remove it from your collection.

Speed Track Wrap-UP

What we have really done here is learned how to enter data, list data, store data, save data, load data and delete data.  These are all very common tasks required by many programs.  Let’s