One of the interesting features of C# is the ability to add custom user controls to your forms. If you have some specific functionality centered around a group of form controls that you use repeatedly, you can save it as a custom control in a class library and then add it to other applications. This is a great example of code reuse and saves a lot of time.
I’m starting to get the hang of creating demo videos with Camtasia and other tools and my latest videos show how to create user controls and implement them within Visual Studio.
Very often, you’ll want your custom controls to communicate with the host application, passing data back and forth and one way to do this is to have your control raise custom events at specific times. The host application listens for these events and responds as it needs to. This is a very powerful ability that enables your classes to interact in more dynamic ways. Once you understand how to raise and catch custom events, you’re no longer dependent on the C# event model and your applications can signal and respond to any condition you want them to.
The second video builds on the first part to show how to add custom events to your classes.
I encourage you to follow along with the videos and try creating the controls yourself. Also, experiment with your own ideas so that you’ll better understand the concepts.
If you would like to read more about creating custom events in C#, you can find more detail on the Microsoft website at the following links:
Summer vacation has mercifully arrived for me and my students. Unlike many teachers, I’m at the school through most of the Summer. My students get three weeks off – I get one week followed by a couple weeks of what will essentially be teacher workdays. Judging from the sympathetic looks I was getting from other staff members and the sudden, dramatic drop-off in attendance of my classes, I’m thinking the break didn’t come a moment too soon.
My latest challenge to my database programming students was to create a C# class that would perform various number conversions, starting with Arabic numbers (0 to 3999) to Roman numerals and vice versa.
I required that all public functions in the class needed to be declared as static, so that they could be called from outside the class without having to create a new instance. Also, the class was to be completely portable; it must not use any functions such as message boxes that would prevent them from copying the entire class into any other type of project and referencing it. Of course, all code must also have error handling and commenting.
My students came up with various solutions and I think some had more help from StackOverflow than others. I know that one of them learned the hard way not to search for “XXX” on Google.
One popular strategy was to use the C# Dictionary class to hold the Roman characters and their equivalents. I don’t always get around to writing up my own solutions to these challenges before I assign them, so I happily swiped that strategy for my own code which was otherwise written from scratch. I ended up using the SortedDictionary class instead.
I started my (more or less) serious database development training many years ago in Microsoft Access. One of my favorite controls was the Combo Box, a nice little drop-down field that enabled the user to select one of many values but collapsed down onto a single line. The Combo Box control in Access was very configurable and one of the nice features was that you could display one value while actually saving another value to the field the control was bound to. For example, you could display the Customer Name while saving the associated CustomerID that the database would use to reference the customer record.
C# also has a Combo Box control that can do much the same thing but offers a lot more options through code. The .NET version maintains a collection of objects, any kind of objects, and displays whatever text is presented by the object’s ToString() method. The code can then use any other property of the object to carry out operations in the background.
The .NET framework has a few different automated methods for managing connections to SQL Server and other databases. The framework has been around since 2003 and various versions have introduced new, improved data management tools while maintaining the old ones for backward compatibility.
It’s still possible, however to retrieve data from SQL Server and other database systems with just a few lines of code and it’s important to know how to do this to truly understand how the communication between SQL Server and a language like C# actually works.
For the past six months, I’ve been teaching night classes in database programming and my students are just about ready to take Microsoft’s 98-364 exam. Now, we’re transitioning over to C# programming for the next phase of the program but I have to keep their SQL skills fresh for the exam. Tonight, it was time to teach them to understand the binary number system. I dropped some hints on it a couple of months back to brace them but now it was time to get it done with once and for all.
Then, as I like to do with this class, I came up with a lesson plan that would incorporate the best of both subjects …
Yes, prime numbers are a go-to challenge for me that I’ve been casually playing with since my earliest programming days. I’m not alone; prime numbers are important and popular enough that there’s an entire distributed computing project dedicated to finding the highest Mersenne Prime number (primes such as 31 and 127 that are one less than a power of 2). A decent grounding in math is also important for programmers and prime number algorithms are a much better programming exercise than “Hello, World”.
That’s why, during a holiday trip to a local Barnes & Noble, I was looking through their collection of quick and shallow knowledge books (“100 Factoids That Will Make You Sound Knowledgeable …” ) and found one called Math Squared: 100 Concepts You Should Know. I wasn’t expecting a degree out of this small, 256-page book but it’s been awhile since math class, I thought it might give me some good ideas for programming exercises and I like the feel and smell of new books. Continue reading →
I recently started studying the Python programming language. I’m getting ready for a new programming-related position next year and one of my colleagues suggested using Python as part of it. I’ve heard of Python more and more over the past several years and I figured now would be as good a time as any to finally learn it.
I can definitely recommend Udemy’s Complete Python Bootcamp by Jose Portilla. This course is written for complete programming beginners and does an excellent job of introducing the fundamentals and guiding the student through various programming concepts. It’s probably more basic than I actually need but it never hurts to go back to school.
Both days will start at 10 a.m.. Attendees are welcome to stay until 10 p.m. on the first day when we’ll be forming teams and beginning to code. The event will wrap up at 5 p.m. on Sunday, Oct 16, when each team will present what they’ve made.
This is an awesome chance for you to put your coding skills to use, build something great and meet other area programmers. Again, attendance is limited to the first 100 people registered so sign up now at http://powerupweekend.eventbrite.com.