Best books/sites on Windows Forms?

  • Thread starter Thread starter Jon Skeet
  • Start date Start date
J

Jon Skeet

I've decided that even if I don't really need Windows Forms for work at
the moment, it would be a good idea to get to grips with them a bit
more fully just for general knowledge purposes.

Can anyone recommend any good books or web sites specifically on
Windows Forms? I'd prefer code in C# if possible, though I don't mind
anything else. I'd also prefer it not to rely on VS.NET too much - I
like to hand-code GUIs to avoid hard-coding in sizes etc where
possible. It's fine to give examples in the VS.NET designer, but it
should explain what's going on as well :)

In particular, I'm currently interested in control layout and sizing.

I'm comfortable with C# and the BCL already.

I've heard good things about Charles Petzold's "Programming Windows
with C#" - any comments on that?
 
Joerg Jooss said:
Petzold is certainly the way to go here -- all his code is handcrafted,
thus not relying on VS .NET. Keep in mind though that his book is about
50% Windows Forms and 50% GDI+ and does not cover control development.
Another book I strongly consider buying is Chris Sells' brand new one
published by Addison-Wesley, but I don't know how much he relies on VS
.NET.

Right. I might treat myself and get both. I've also read good things on
Amazon about Windows Forms Programming with C# by Erik Brown and User
Interfaces in C#: Windows Forms and Custom Controls by Matthew
MacDonald. I think I'll get one of the four in question, see how it
goes, and then consider getting another :)
 
Jon said:
Right. I might treat myself and get both. I've also read good things
on Amazon about Windows Forms Programming with C# by Erik Brown and
User Interfaces in C#: Windows Forms and Custom Controls by Matthew
MacDonald. I think I'll get one of the four in question, see how it
goes, and then consider getting another :)

Erik Brown's book is a good tutorial (you build a complete app), but
relies heavily on using VS .NET. The MacDonald book is good as well, and
covers Windows Forms Control development quite nicely.

[Amazon just has to love me...]

Cheers,
 
Joerg Jooss said:
Erik Brown's book is a good tutorial (you build a complete app), but
relies heavily on using VS .NET. The MacDonald book is good as well, and
covers Windows Forms Control development quite nicely.

Great - thanks for the extra detail. Do any of them specifically cover
layout in any great detail? This book-buying idea came about when I
failed to find a simple way of creating a form which contained three
GroupBoxes which should be laid out vertically to their "natural" size,
preferrably without me having to do much explicit size specification.

I don't do much GUI programming in any language/platform, but in Java
this would be fairly easy to do - it so far it seems it's a bit of a
pain in .NET, which probably means I've missed something important.
 
Jon said:
Great - thanks for the extra detail. Do any of them specifically
cover layout in any great detail?

Petzold and Brown just explain the Anchor and Dock properties. MacDonald
goes a little further here and describes typical layout scenarios.
This book-buying idea came about
when I failed to find a simple way of creating a form which
contained three GroupBoxes which should be laid out vertically to
their "natural" size, preferrably without me having to do much
explicit size specification.

Hm. What about docking three Panels (DockStyle.Top, .Fill, .Bottom) and
placing one GroupBox in each?
I don't do much GUI programming in any language/platform, but in Java
this would be fairly easy to do - it so far it seems it's a bit of a
pain in .NET, which probably means I've missed something important.

There are no LayoutManager classes in Windows Forms like the ones found
in AWT or Swing; instead, each Control has the aforementioned Dock and
Anchor properties that control resizing behavior. Did you try them?
 
Joerg Jooss said:
Petzold and Brown just explain the Anchor and Dock properties. MacDonald
goes a little further here and describes typical layout scenarios.
Right.


Hm. What about docking three Panels (DockStyle.Top, .Fill, .Bottom) and
placing one GroupBox in each?

I suspect I could actually just dock the three group-boxes themselves,
yes. But do I need to specify the size of the top and bottom ones, or
will they be magically the natural size?

(Also, I could do with making it non-resizable, as it won't make any
sense to resize it - I haven't found any way of doing that other than
by making the maximum and minimum size the same, and even that doesn't
stop the user from *trying* to resize it. I'm sure I've just missed
something there.)
There are no LayoutManager classes in Windows Forms like the ones found
in AWT or Swing; instead, each Control has the aforementioned Dock and
Anchor properties that control resizing behavior. Did you try them?

I've tried them briefly, but as far as I can see they only give a
fairly coarse level of control compared with the Java layout managers,
in terms of how much space is given to each control when the form is
resized, etc. I'm sure I'll get more used to them - I can just see
myself creating more panels solely because I can't easily have more
than three things vertically or horizontally stacked, etc. That's okay
though - it's just a change in paradigm.
 
Back
Top