[.net] Windows forms programming (not using design editor)

Started by
7 comments, last by Arild Fines 19 years, 5 months ago
I have learned the basics of the language and I want to learn Windows Forms programming. I have a book that touches upon the subject (Programming C# by D&D), but it uses the design view mess. I want to understand what's going on underneath the hood before I go about drawing my objects. I also think that learning to do things programmatically would help a bit since my next main goal is to write a game, probably pong. But obviously, first I need to learn windows forms. Summary of my blabbering: Does anyone know any online tutorials that teach Windows Forms programmatically? Thank you.
Dat is off da hizzle fo shizzle dizzle
Advertisement
It's actually quite simple. This page: Windows Forms with no VS.NET shows you a very basic WinForms app which you can write in notepad.

Heck, you can even start writing your WinForms app in the IDE and then when you're happy, just expand the "Designer Generated Code" region and modify it to your heart's content.

The best resource, as always, is MSDN which describes all the classes in the System.Windows.Forms namespace very well.
I think Dean touched on something important. The form designer doesn't hide anything from you. It generates the code you would have written anyway in a region called something like "Form Designer Generated Code".

If I wanted to learn a lot about how to make windows, I would make some windows in the form designer, and then check out the code it generated in the source file.
You might consider "C# and the .NET Framework" by Robert Powell and Richard Weeks.
Behold the nascent power of Semejant!
Quote:Original post by Dean Harding
Heck, you can even start writing your WinForms app in the IDE and then when you're happy, just expand the "Designer Generated Code" region and modify it to your heart's content.

You better move it out of that region/method then - VS will overwrite your changes if you ever open the designer on that form again(which isn't all that unlikely, considering that the design view is the default view for a form).
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
The Charles Petzold book, "Programming Windows With C#", doesn't use the forms designer at all. He's very focused on GDI+, though.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Quote:Original post by Arild Fines
Quote:Original post by Dean Harding
Heck, you can even start writing your WinForms app in the IDE and then when you're happy, just expand the "Designer Generated Code" region and modify it to your heart's content.

You better move it out of that region/method then - VS will overwrite your changes if you ever open the designer on that form again(which isn't all that unlikely, considering that the design view is the default view for a form).


Really? I thought that modifying things like sizes and such yielded the equivalent results in the form designer.

Matt
VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.
Quote:Original post by Arild Fines
Quote:Original post by Dean Harding
Heck, you can even start writing your WinForms app in the IDE and then when you're happy, just expand the "Designer Generated Code" region and modify it to your heart's content.

You better move it out of that region/method then - VS will overwrite your changes if you ever open the designer on that form again(which isn't all that unlikely, considering that the design view is the default view for a form).

Yeah, I 'hacked' one of my programs by making lots of labels static and WFD just deleted them all. I wasn't best pleased.
Quote:Original post by CpMan
Really? I thought that modifying things like sizes and such yielded the equivalent results in the form designer.

Those kinds of things probably persist. I was thinking more of adding lines, changing them completely etc.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement