Hello everyone,
I am a beginner to C# programming and I want to do a custom form for my local database to add edit and delete records. Now I can do all of that with drag and drop but the problems are errors. How can I add exceptions to errors for example if I click the add button the solution breaks and I got the message "No Null Allowed Exception was unhalded". What should I do to fix this problem?
Please help.
Best regards,
Konstantin.
1 Replies - 1737 Views - Last Post: 15 February 2012 - 10:13 AM
Rate Topic:




#1
konstantin79
C# Custom form to add, read and delete data in local database
Posted 15 February 2012 - 10:04 AM
Replies To: C# Custom form to add, read and delete data in local database
#2
tlhIn`toq
Re: C# Custom form to add, read and delete data in local database
Posted 15 February 2012 - 10:12 AM
See FAQ 21 for database tutorials.
TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Form1 talk to Form2
FAQ (Frequently Asked Questions - Updated Feb 2012[HR]
But when it comes to the larger issue of "How to I handle exceptions?" and "I'm new to C# but I want to write a program from scratch anyway"...
I will make a common suggestion: Quit trying to develop your own application before you lean *how* to code in your chosen language. Trying to write a program from scratch as a learning exercise never works this early in your schooling.
This type of thing is covered very early on in any self-teaching book. Which makes me think you really aren't ready to be designing an application yet.
Some of the tutorials below are for C# not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.
You need to start there. I can't say "I have little experience in speaking Russian, but I have been assigned to write a mystery novel in Russian. Can you help me?"
We can help you by saying "First learn basic programming and the language of C#. Then take on assignments." Could someone here write this program for you? Sure. Could someone here map out all the processes you need to follow and do the Software Design part of this in the slim hope you could code it from there? Sure. But we don't volunteer to do the job that you're either getting paid for, or getting a grade for. You may want to read this.
For now, just work on the lessons. Do a self-teaching book from cover to cover. Then consider writing a program.
Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."
I don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).
Resources, references and suggestions for new programmers. - Updated Jan 2012
TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Form1 talk to Form2
FAQ (Frequently Asked Questions - Updated Feb 2012[HR]
Spoiler
- My program is broken:
- Q: My program doesn't work. I didn't show you any code or actually tell you the error message. How do I fix it?
SpoilerA: What have you tried so far? It is a requirment of this site that you at least make an effort to research (read the MSDN) and code a good faith effort for your own problem. Can you share your current code with us and better explain what issues or errors you are getting? Give us something to go on
- Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?
A:Spoiler
How do I?
- Q: ...get Form 'A' to make a change or talk to Form 'B'
SpoilerA:- See this thread for the simplest of example code between two forms.
The tutorials below actually teach and explain it further. - Passing values between forms/classes
- Bulding an application - Part 1
- Building an application - Part 2
- Quick and easy custom events
- See this thread for the simplest of example code between two forms.
- Delegates, Lambdas and Events
- Q: ...make a password/login form?
A: Password handling tutorial
- Q: ... browse for/open a file?
Read this tutorial
- Q: ...make a chat or client-server application?
A:Client/server chat tutorial
Peer-to-peer chat
- Q: ... get my program to programmatically simulate a mouse click or button press?
A: Simulate mouse and keystroke (even to another application)
- Q: ... save data, save properties, save environmental variables, serialize my data/class?
A:Spoiler
- Q:... get sound in my program?
A: Adding sound to your C# application
- Q: ... use the serial port?
A: Serial port communication
- Q: ...do compression or .zip files?
A:
- Q:...do multi-threading? Having a problem with cross-threading...
Spoiler
- Q: ... make my textbox offer suggestions as the user types. (Autocomplete)
A: Creating an auto-complete textbox
- Q: ... make a textbox just accept numbers and not letters?
A: Read this thread - Q:I get an error when I try to use a textbox for numeric values and the user types non-numbers. What do I do?
A:SpoilerWe see this a LOT, especially with rookies using textbox for numeric input.
Any input that can't be converted to a number will do this.
"5" can become 5
"yogi" cannot become a number
string.empty cannot become a number
You would be best off changing from a textbox to a NumericUpDown or to inherit from textbox to make a numerictextbox.
There are a LOT of articles on making a NumericTextBox. Try googling "C# NumericTextBox" and you should find a lot, such as this one on the MSDN:
http://msdn.microsof...4(v=vs.80).aspx
Once you study the code you'll see that as each key is pressed it is checked to see if it is a number. If not, then it is ignored. Thus the user can only enter numerically valid values.
- Q: ... use PInvoke and the Win32 api calls to get functions not available in .NET framework?
A: Using the Win32 API Tutorial
- Q: ... have both a WinForms Windows app, and still have a Console window open?
SpoilerA: Make your new project a WinForms project. Then go back to project properties (Right-click on the project, select Properties).
On the Application tab go to the dropdown that says "Windows Forms" and change it to "Console Application." You now have a WinForms application with a console window. I do this on occassion to see my Console.WriteLine statements when I am debugging. But don't consider this mixed mode operation a proper way to release an application for real-world use.
- Q: ... make a username/password logon (login) system?
A: Read this tutorial
Can someone explain...
- Q: ... how to do x, y, z with the HTML that comes out of a website ...
A: Check out the HTML Agility Pack. Yes its free.
- Q:... how to do x,y,z with a database {probably for the first time}...
A: Read this tutorial
Entire section of tutorials
- Q: Can someone explain bitwise operations?
A: Terrific explanation by CodingSup3rnatur@l-360. Be sure to +1 him for this thread.
I'm lost while learning xyz... I don't know where to begin...
- Q:I'm trying to teach myself programming. I'm writing a program to do xyz, rather than following a guided self teaching book or lesson plan or on-line tutorial because I just don't learn from books.
A:SpoilerI'm sorry for how this sounds. I tend to take the stance that I can do you more good and give you more long-term meaningful help by being frank and give you adult-level honesty. I don't feel it does anyone any good to coddle them and do nothing but blow sunshine and rainbows up their skirt. I'd rather say something to motivate you than feel my place is to bolster your false high self esteem.
Quote
]
I've tried going through those, the only way im learning is through struggling to write code from scratch, the thought process i guess is helping me, i've tried reading sooo much and watching videos but honestly im not learning until i actaully type it.
I hear this a lot and the only thing I can think is students are buying the wrong books. Or they read the information and don't feel they need to actually work the lessons/exercises. This argument sounds like there are only two choices:
- Develop from scratch even though they haven't learned the language yet.
- Just read C# dictionaries.
Maybe this is from students buying the course textbook and reading it on their own, without the benefit of the teacher and their lesson plan and exercise assignments. When one mis-uses the materials, or only has 25% of the materials, of course they won't learn.
Here's a tip when selecting a book: If it is a dictionary of the language it is not a teaching book. Titles like "C# 4.0, The Complete Language" are not teaching books. If the title includes the words "Learn" or "Master" or "Teach" they might be teaching books. "Learn C# in 21 days", "Master C# in 2 hours a night", "Head First C#, A self-teaching guide" Then they are probably teaching books with a lesson plan and exercises to help you build up skills.
Obviously you didn't read the resources list I posted or get any one of the NUMEROUS self-teaching books.
Self-teaching books HAVE YOU TYPING CODE. They are NOT just reading as you describe.
C# is a language just like Russian or English. You cannot learn Italian by just reading an Italian dictionary. Or even reading an English-to-Italian dictionary. You have to take lessons and do the learning exercises. Those lessons and exercises are developed by professionals to take place in a sequence proven to work, by taking the student from simple to complex concepts. You did not learn how to compose literary works in English by just reading a dictionary. You worked at lessons that taught you the syntactical use of verbs, nouns, additives and so on. You worked lessons that had you build simple things first like "Those are my apples. These are your pencils", and worked up from there.
So why are you trying to "just read" to learn C#? Or why are you insisting on trying to design and code a working program without first learning the language? It makes no sense! Its like saying you have to design and write a mystery novel as your introductory educational process to learn German. Its just a fraking ridiculous argument to try to take or defend.
There are numerous on-line learning series on the internet that have you learning and WRITING code, not just reading. We have them right here on DIC and they have been linked to you several times. There are many good guided self-teaching books, that once again are NOT just reading but teaching through proven methods of:
- Introduce new material
- Have student exercise with new material
Yet you insist that you don't need to go the route that has worked for the 3 generation of coders before you: Representatives of which are here TELLING you that is the way to learn this science/skill/art.
Quote
would i be able to take out the private double[] months = new double[12];
and place it in a method instead of leaving it in a private field, why does it have to be in a private field as opposed to a method in just placing it in the main method?
Questions like this last one show just how badly you need to stop trying to write this program and just concentrate on learning the language through some sort of guided lesson plan. This question is filled with so much lack of understanding that it is hard to know where to start in an effort to answer it. To answer this someone would have to back up 5 chapters and help you get a grasp of certain introductory concepts. It's not right to ask that of people that have already devoted tens or hundreds of hours to develop the tutorials we have here. You shouldn't be asking them to repeat themselves because you feel you need special hand-holding or because you don't want to get the right books or because you don't want to actually work the exercises in the books or tutorials.
- Develop from scratch even though they haven't learned the language yet.
- Q: I am making a calculator as my school homework project and ...
A: Calculator tutorial
- Q: I've been struggling with this for days/weeks and I can't figure it out and my professor is worthless and can't teach. Can someone here explain it to me?
A:SpoilerIf you are struggling with how to do this you need to talk to your professor. Let him/her know you are struggling at this early stage in class. Make your professor do the job (s)he gets paid to do by either helping you or finding you a tutor or giving you more exercises from earlier in the book. You are paying for this education. Be an active part in not allowing the teacher to brush you off and let you slip through the cracks. If the other 50 people in class aren't struggling then don't blame the teacher. If the other 50 people are struggling then you all need to go to the professor's superior and tell him/her. If the prof is really incompetent then you don't need to help him keep his cushy 100,000/year job. If the prof isn't incompetent then you need to study harder or consider buying another book on programming. You aren't required to ONLY use the text book provided for the class.
"How do you resolve your issues" survey.
- Q:
Quote
Hi,I'm currently learning C# in class at the moment and I'm a little bit stuck on what this question means.[...]show me where I can get help,
A:SpoilerYour professor. That's where to start for a couple reasons:
1. They are getting paid to teach you. If they aren't teaching you this needs to come to their attention and that of their superiors.
2. You're the one paying them. Tens of thousands of dollars for your education. You need to learn to take every ounce of knowledge you can from these teachers and not sit passively back and try to learn it on the outside. If you were going to do that then you didn't need to take out all the student loans that are going to keep you in debt for the next 15 years.
3. You need to let the teacher do their job. If you are struggling here you don't want to hide it. You need them to be aware of position so they can give you the time and attention you need. Otherwise you will be a little lost on chapter 1. A little more on 2. Way behind by chapter 3. You have to get a good foundation now if you are to gain anything in the later lessons.
- Q: I want to write a program that does x, y and z with features for A, B, and C. {Notice there is no question in this question}
A:SpoilerThat is a very good statement of intent. Go right ahead. You don't need to announce your intentions to us, nor get anyone's permission. After you have made an effort to your own code (in good faith as described in the Welcome DIC email you got when you joined) and the forum rules that I'm sure you read before posting, and you have a QUESTION about this project... Please post the QUESTION here in this same thread. There is no need to start a new thread for this same topic.
- Q: I need to code to do x... Someone tell me the code for y...
A:SpoilerYour question is about to get bounced for begging for code anyway but...
So you're asking the volunteers here to write your code for you, to make it do everything in your wish list?
Please read the rules. You seem to misunderstand what we do here. We help people learn to code. We help people with their projects. We help people better understand the errors and exceptions they are getting so they can fix their issues. We are not a free code writing service. If you have made an effort to code a specific feature, but are not getting the results you wanted then please post the relivant code for that feature along with the error messages or an explanation of what results you are seeing as compared to the results you were expecting, and we will try to guide you onto the right path.
Read this article!!!!!
Discussion topics:
- Q: What is the best programming language/OS? What programming language/OS should I learn?
A:SpoilerAll of them. And none of them. You might as well be asking "What is the best kind of vehicle?" Because the answer for both questions is "It depends on your needs and what personally suites you the best." C, C++, C#, Objective-C, Cocoa, F#, Visual Basic, Python, JAVA...
Are all good languages. They all have their pros and cons. They each have their strengths and weaknesses. Some have stronger footholds in some markets than others. Do you want to write for iPhone/iPad then you need Objective-C. Do you want to write for generic mobile phone use then you need JAVA. And so on. If you have no idea what area of programming you want to move to (Gaming, Financial, Windows, Macintosh, Cell phones) then nobody can advise you on a language. Personally, I would point you to C# because, like it or not, Microsoft owns the desktop computer market and C# will teach you good habits of design, OOP (Object Oriented Programming) design, inheritance and so on: Concepts that translate well to all other OOP languages.
The OS is a by-product of the type of coding you want to do, which in turn dictates the language you need, which then decides the operating system you probably need. Not the other way around.
Do you want to code apps for iOS devices like the iPad and iPhone? Then you need a Macintosh to do it right. Are you hankering to do machine vision programming? Industrial robot control? Financial applications?
What are your programming goals? Do you want to market $9.99 desktop applications to the masses? Do you want to make control systems for
helicopters? XBox games requires the .NET XNA framework so you are now in Windows. Do you want to do embedded controls for automotive computers? Do you just love MS Office and love to make extensions for it? Do you want to work on web apps or desktop apps or mobile apps?
Do you now see why we can't even begin to tell you what is best for you? Only you know what you like and what you don't like. Only you know what area of programming is interesting to you. If you ask me for advice I might tell you video processing for the movie industry is great so you should get a Mac. Someone else is going to tell you cool stories of working on CSI lab equipment so you should do C embedded stuff.
The short answer for this question is: Get in touch with your own wants and needs then think for yourself.
Join this heated discussion on the topic:
http://www.dreaminco...anguage-to-use/
VB6 is dead
- Q: How do I become a programmer?
A: Click the link
- Q: I'm not really sure what I want to do with my future? Do you guys like programming? I think I kinda like math and games and computers? What should I do or study?
A:Spoiler
You are asking a very vague, generalize question about a broad topic.
You might as well be asking... What is the best kind of vehicle to buy? Or what is the best kind of plastic to make? It all depends on your needs... Your area of business.
If you are interested in embedded devices like computers that control automobile engines it is still programming - but it is entirely different to writing a point of sale program meant to be used as a self-service kiosk like you see at Home Depot. And that is entirely different to writing a program that is meant to be used on a mobile platform.
You need to make a decision about what kind of programming, what area of interest, what industry you want to work in, before you can worry about the specifics of which language and OS and platform.
Which Language Should I Learn?
DIC Tutorials Section
Good thread on the topic
Get experience while you find yourself
- Q: What's your installation like? What sofware do you use? What are your Visual Studio extensions?
A:Spoiler
- Host Operating System - 16gig, quadcore, 3x24" Dell LCDs at 1920x1200 (2 landscape, 1 portrait)
- 20 times of on-line update/reboot cycle
- Device Drivers
- AVG antivirus
- VMware workstation
- VM Operating System
- 20 times of on-line update/reboot cycle
- Device Drivers
- Visual Studio
- ReSharper
- Dotfuscator
- nArrange
- XAML regions
- XAML code cleanup
- InstallShield
- ReSharper
- Expression blend studio
- MS Office
- SnagIt
- Safari
- iTunes
- Fences
- Yahoo messenger
- FoxIt PDF reader
- AnyDVD (I have DVDs from 3 different regions)
- TightVNC
- Dropbox
- AVG anti-virus
- Quicken
- Canon RAW codec
- Shark007 codec pack for Media Center
- Another 20 rounds of on-line update/reboot
- Take a snapshot of the VM machine for easy restoration
- 20 times of on-line update/reboot cycle
- 20 times of on-line update/reboot cycle
That is my entire install
Working for myself/Deploying/Selling software:
- Host Operating System - 16gig, quadcore, 3x24" Dell LCDs at 1920x1200 (2 landscape, 1 portrait)
- Q:How do I stay a free lance coder for a living?
A:http://justcreatived...eelancing-life/
- Q: How do I become a better coder?
Read this, and practice a lot.
How to be a better coder
- Q: Are there any resources for small C# projects a novice to become a better coder?
A:SpoilerThere is a novice projects thread here on DIC. But here's my advice whenever this comes up:
Look around. Anyone who can't find a dozen projects a day by just walking through life, is doing so with their eyes closed to the world.
- Do you like the weather? What about a program to get the various weather reports from different web sites? Or to integrate with one of the numerous USB weather station hobby kits on the market?
- Do you like the run? What about a program to log your runs, routes and progress?
- Do you like movies? What about a program to catalog all your DVD's and AVI's?
- Do you like photography? What about a program to browse your images, assign tags and GPS?
- Do you like shooting? What about a program to track your aim and improvement?
- What about every time you walk into a business and someone says "Oh, I'm sorry. The computers are slow/suck. This is going to take 10 minutes and 25 screens." Sounds like an opportunity to make and maybe even sell them a new program. So go home and make it first before you open your mouth. If you succeed in something great. If you fail, then you know where to study more and you haven't embarrassed yourself.
What about every time you walk into a business and someone says "Oh, I'm sorry. The computers are slow/suck. This is going to take 10 minutes and 25 screens." Sounds like an opportunity to make and maybe even sell them a new program. So go home and make it first before you open your mouth.
If you succeed in something great. If you fail, then you know where to study more and you haven't embarrassed yourself.
Go to any of the on-line coder for hire sites. Read the new contract descriptions. DON'T BID ON THEM. Just read them. This will tell you what is requested by employers so you know where you have the potential to make money, and tell you where you should study. Then pick a project and build it. TRACK YOUR TIME. If you don't know how long it takes you to build a project then you won't be able to bid on contracts. If you bid $50 for 50 hours of work you're going to starve to death. Again, building projects just to learn the technology and learn your own speed and weaknesses is something we all do/did and you need to do too. Once you can build a project just for the learning experience, fast enough that you could have made a competitive bid... Now you can start considering actually bidding on new contracts that are in your skill set.
- Do you like the weather? What about a program to get the various weather reports from different web sites? Or to integrate with one of the numerous USB weather station hobby kits on the market?
- Q: How do I sell the software I've developed?
A:http://www.dreaminco...m_notifications
- Q: How do I decide how much to charge for my application?
A: Read this
- Q: How do I deploy my program / Make an installer?
A: C# application deployment project
Include the smallest .NET possible
But when it comes to the larger issue of "How to I handle exceptions?" and "I'm new to C# but I want to write a program from scratch anyway"...
I will make a common suggestion: Quit trying to develop your own application before you lean *how* to code in your chosen language. Trying to write a program from scratch as a learning exercise never works this early in your schooling.
This type of thing is covered very early on in any self-teaching book. Which makes me think you really aren't ready to be designing an application yet.
Some of the tutorials below are for C# not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.
Newbie/Rookie said:
I have a little programming experience but I need to write ...
You need to start there. I can't say "I have little experience in speaking Russian, but I have been assigned to write a mystery novel in Russian. Can you help me?"
We can help you by saying "First learn basic programming and the language of C#. Then take on assignments." Could someone here write this program for you? Sure. Could someone here map out all the processes you need to follow and do the Software Design part of this in the slim hope you could code it from there? Sure. But we don't volunteer to do the job that you're either getting paid for, or getting a grade for. You may want to read this.
For now, just work on the lessons. Do a self-teaching book from cover to cover. Then consider writing a program.
Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."
I don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).
Resources, references and suggestions for new programmers. - Updated Jan 2012
Spoiler
Here's how I look at doing tutorials even if one has a coding background that makes one think they don't need to do tutorials:
The stages of asking for homework help on a forum
Finding answers to specific problems:
Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.
How to do a good search that will get you targeted answers.
Once you have that MSDN page that describes the function, you may not be familiar with out to actually get useful information from that page. There is a LOT of data there. So what is the important parts? Read this guide to reading the MSDN.
Don't think you are the first person to ask a question. Try a search on this site to see if someone has already brought up this problem. Also, as soon as you post your question go to the bottom of the updated page: You will see where the system has already analyzed your question and tried to find similar threads for the same question, so check those links out.
But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language throughbanging on the keyboard experimentation - or you can learn by doing the tutorials and following a good "How to learn C#" book. There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" type books at your local book seller or even public library.
Beginner:
C# Fundamentals: Development for absolute beginners (video series)
Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5 is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.
Martyr2's mega project ideas list is a great place to start on developmental projectst that you can learn from; rather than trying to make something complex like a game as a self-teaching tool {that never works for anyone}
Visual Studio Keyboard Shortcuts
D.I.C. C# Resource page Start here
Intro to C# online tutorial then here...
C# control structures then here.
MSDN Beginner Developer video series
MSDN video on OOP principals, making classes, constructors, accessors and method overloading
MSDN Top guideline violations, know what to avoid before you do it.
Design patterns as diagrams
I hate sending people to another site when we have such good tutorials here, but this series shouldn't be overlooked.
Programming OOP in C# - Part 1
Programming OOP in C# - Part 2
Programming OOP in C# - Part 3
Programming OOP in C# - Part 4
Programming OOP in C# - Part 5
Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on.
Writing a text file tutorial.
Reading a text file tutorial.
Have you seen the 500+ MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.
Intermediate:
Microsoft Events (webcasts and podcasts)
The tutorials below walk through making an application including inheritance, custom events and custom controls, object serialization and more.
Quick and easy custom events
Bulding an application - Part 1
Building an application - Part 2
Separating data from GUI - PLUS - serializing the data to XML
WPF version (WPF-MVVM data binding)
Passing values between forms/classes
Decouple your multi-threaded work from the GUI so forms don't hang
Working with environmental variables
'Why do we use delegates?' thread
And everyone always wants to connect to a database, right out of the gate so Database tutorials right here on DIC
C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.
Everyone:
Debugging tutorial
Debugging tips
Debugging in detail
Great debugging tips
It still doesn't work, article
I urge you to work through the C# learning series here on DIC, and to work a self-teaching book from cover to cover before you even think about designing your own applications.
Microsoft Visual Studio Tips, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5 Has many, many great, real-world tips that I use all the time.
These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio
Free editions of Visual Studio 2010
Windows Presentation Foundation:
Create Animations Programmatically
Let me also throw in a few tips:
Quote
I already have a background in programming from this other software/technology/lanugage so I don't think I need to do tutorials
Here's how I look at doing tutorials even if one has a coding background that makes one think they don't need to do tutorials:
- If one's background really is enough to not need the tutorials, then they won't take long - So what's the harm?
- If the tutorials do take a while, then it might be time to re-think how much of one's old experience really applies to the new technology.
- There's no down-side. Every tutorial/series teaches something in a new way. Maybe you pick up a neat trick or a different approach to something that you already knew.
The stages of asking for homework help on a forum
Finding answers to specific problems:
Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.
How to do a good search that will get you targeted answers.
Once you have that MSDN page that describes the function, you may not be familiar with out to actually get useful information from that page. There is a LOT of data there. So what is the important parts? Read this guide to reading the MSDN.
Don't think you are the first person to ask a question. Try a search on this site to see if someone has already brought up this problem. Also, as soon as you post your question go to the bottom of the updated page: You will see where the system has already analyzed your question and tried to find similar threads for the same question, so check those links out.
But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language through
Beginner:
C# Fundamentals: Development for absolute beginners (video series)
Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5 is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.
Martyr2's mega project ideas list is a great place to start on developmental projectst that you can learn from; rather than trying to make something complex like a game as a self-teaching tool {that never works for anyone}
Visual Studio Keyboard Shortcuts
D.I.C. C# Resource page Start here
Intro to C# online tutorial then here...
C# control structures then here.
MSDN Beginner Developer video series
MSDN video on OOP principals, making classes, constructors, accessors and method overloading
MSDN Top guideline violations, know what to avoid before you do it.
Design patterns as diagrams
I hate sending people to another site when we have such good tutorials here, but this series shouldn't be overlooked.
Programming OOP in C# - Part 1
Programming OOP in C# - Part 2
Programming OOP in C# - Part 3
Programming OOP in C# - Part 4
Programming OOP in C# - Part 5
Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on.
Writing a text file tutorial.
Reading a text file tutorial.
Have you seen the 500+ MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.
Intermediate:
Microsoft Events (webcasts and podcasts)
The tutorials below walk through making an application including inheritance, custom events and custom controls, object serialization and more.
Quick and easy custom events
Bulding an application - Part 1
Building an application - Part 2
Separating data from GUI - PLUS - serializing the data to XML
WPF version (WPF-MVVM data binding)
Passing values between forms/classes
Decouple your multi-threaded work from the GUI so forms don't hang
Working with environmental variables
'Why do we use delegates?' thread
And everyone always wants to connect to a database, right out of the gate so Database tutorials right here on DIC
C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.
Everyone:
Debugging tutorial
Debugging tips
Debugging in detail
Great debugging tips
It still doesn't work, article
I urge you to work through the C# learning series here on DIC, and to work a self-teaching book from cover to cover before you even think about designing your own applications.
Microsoft Visual Studio Tips, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5 Has many, many great, real-world tips that I use all the time.
These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio
Free editions of Visual Studio 2010
Windows Presentation Foundation:
Create Animations Programmatically
Let me also throw in a few tips:
- You have to program as if everything breaks, nothing works, the cyberworld is not perfect, the attached hardware is flakey, the network is slow and unreliable, the harddrive is about to fail, every method will return an error and every user will do their best to break your software. Confirm everything. Range check every value. Make no assumptions or presumptions.
- Take the extra 3 seconds to rename your controls each time you drag them onto a form. The default names of button1, button2... button54 aren't very helpful. If you rename them right away to something like btnOk, btnCancel, btnSend etc. it helps tremendously when you make the methods for them because they are named after the button by the designer.btnSend_Click(object sender, eventargs e) is a lot easier to maintain than button1_click(object sender, eventargs e)
- You aren't paying for variable names by the byte. So instead of variables names of a, b, c go ahead and use meaningful names like index, timeOut, row, column and so on. You should avoid 'T' for the timer. Amongst other things 'T' is commonly used throughout C# for Type and this will lead to problems. There are naming guidelines you should follow so your code confirms to industry standards. It makes life much easier on everyone around you, including those of us here to help. If you start using the standards from the beginning you don't have to retrain yourself later.
You might want to look at some of the naming guidelines. Its a lot easier to start with good habits than to break bad habits later and re-learn.
- Try to avoid having work actually take place in GUI control event handlers. It is usually better to have the GUI handler call other methods so those methods can be reused and make the code more readible.
Spoiler
btnSave(object sender, eventargs e) { SavePreferences(); } SaveMenuItem(object sender, eventargs e) { SavePreferences(); } SaveContextMenu(object sender, eventargs e) { SavePreferences(); } FormMain_Closing(object sender, eventargs e) { if (IsDirty) SavePreferences(); }
- Don't replace lines of code that don't work. Instead comment them out and put your new attemps below that. This will keep you from re-trying the same ideas over and over. Also, when you come back to us saying "I've tried this 100 different ways and still can't get it", we can actually see what you tried. So often a failed attempt is very very close and just needs a little nudge in the right direction. So if we can say "See what you did in attempt 3... blah blah" it helps a lot
Spoiler// Try #1 - May 1, 0900hrs // code // code // code // Try #2 - May 2, 1700hrs Okay, plan B. What if I do it *this* way // code // code // code // Try #14 - May 3, 0500hrs after 5 cans of RedBull. Maybe I should get some sleep. I can't think of anything else but this last idea code code code
If you are using Visual Studio you can select a block of lines and hit control+k control+c (Kode Comment) to comment it out. control+k control+u (Kode Uncomment) to uncomment a selected block.
- I strongly suggest installing VMware or some other virtualization technology on your development PC so you can create a couple virtual computers for testing. This would allow you to debug and test inside: WinXP32, XP64, Vista, Win7x32, Win7x64... etc. without having to actually have 5 physical PC's. Visual Studio will let you send the debug directly into one of these virtual machines so you can watch it operate, check its variables, see the crashes and so on just as if it were debugging on your real machine.
- This can't be stressed enough in today's world of cell phone messaging:
Don't use txt/sms/leet/T9 speak like: u no, u r, dnt, wut i m do-n, coz, al gud, b4, ny1, and so on like this guy:
Spoilerdis not b d'hood dawg... You are sitting at a real keyboard with a real monitor, not a cell phone. You are not here texting your high school posse to come to your kegger after their shift at Taco Bell. You are here asking for help from senior coding professionals who graciously donate their valuable time to helping the next generation of coders with their chosen craft. Please try to show them, yourself and the industry some respect by writing at least at an eighth grade level. (IE: English not ebonics or SMS, real words, punctuation and so on). If you can't take your own problem/question seriously enough to write like an adult, then why would you expect anyone else to take it seriously?
When you write a post you are presenting yourself. Your writing style is all you have to show others who you are and what you stand for. When I see posts filled with lack of capitalization, SMS text like 'Urself', lack of punctuation and so on; what I see is someone who just doesn't care to make even an eighth grade presentation of themselves. I also see that you feel we are not worth the effort. Posts that look like this show that you don't feel the person you are talking to is worth speaking to as an adult. If you show this level of contempt or apathy towards someone you are asking for help how can you expect to be taken seriously or expect to receive that expert's fullest attention and time to help you?
Page 1 of 1
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|

New Topic/Question
Reply

MultiQuote




|