Looking for a book on C# forms
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
-
Thanks Richard, but I've tried searching using Google with not much luck. I was hoping that if someone who owns a book, on the subject I'm seeking then prehaps they could recommend the book to me. There are some internet sites that display creating a form but many just show you how to place objects on the form, I'd like to know more about the code. Others just give you bits of the code and not the entire code. I'm also seeking example code for forms. Brian
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
Brian_TheLion wrote:
a lot of them are aimed at console programming
No, most "beginner" books start with the console because it's really easy to get immediate feedback for beginners - they don't have to worry about the complexities involved in setting up a website, or creating a form and getting input and output controls onto it; the beginner can focus on learning the real basics of development. They move to websites, WinForms, WPF, later when the learner is familiar with variables, flow control, collections, and so forth. Think about it: which is easier for a beginner to create:
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}Or
using System;
using System.Windows.Forms;namespace HelloWorldForms
{
/// /// Main form for application
///
public partial class FrmMain : Form
{
#region Constants
#endregion#region Fields #region Internal #endregion #region Property bases #endregion #endregion #region Properties #endregion #region Regular Expressions #endregion #region Enums #endregion #region Constructors /// /// Default constructor /// public FrmMain() => InitializeComponent(); #endregion #region Events #region Event Constructors #endregion #region Event Handlers #region Form /// /// Restore size and location (if the user doesn't /// override it) /// /// /// private void FrmMain\_Load(object sender, EventArgs e) { if ((ModifierKeys & Keys.Shift) == 0) { this.LoadLocation(); } } /// /// Save the size and location (if the used doesn't /// override it) /// /// /// private void FrmMain\_FormClosing(object sender, FormClosingEventArgs e) { if ((ModifierKeys &
-
Thanks Richard, but I've tried searching using Google with not much luck. I was hoping that if someone who owns a book, on the subject I'm seeking then prehaps they could recommend the book to me. There are some internet sites that display creating a form but many just show you how to place objects on the form, I'd like to know more about the code. Others just give you bits of the code and not the entire code. I'm also seeking example code for forms. Brian
It is very difficult to make specific recommendations as their usefulness depends very much on the reader's experience and ability. The first C# book i ever worked on was .NET Book Zero by Charles Petzold[^] which is all console based, but gives an excellent grounding in the actual C# language. From there I read various CodeProject and other articles to get an idea of how to use Windows Forms. But the problem is that it is a huge subject and it is not something you can learn in a few days (despite the claims from some websites). Go and explore some of the links in the two Google searches I gave you and see which sites, books etc., you find useful.
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
Is Windows Forms a requirement? A major part of C# GUI programming today is done with WPF, Windows Presentation Foundation. You can easily fill a shelf with books on WPF. (Some of them unforunately spends a lot of words explaining how WPF differs from Forms, more or less assuming that you already know Forms!)
-
Brian_TheLion wrote:
a lot of them are aimed at console programming
No, most "beginner" books start with the console because it's really easy to get immediate feedback for beginners - they don't have to worry about the complexities involved in setting up a website, or creating a form and getting input and output controls onto it; the beginner can focus on learning the real basics of development. They move to websites, WinForms, WPF, later when the learner is familiar with variables, flow control, collections, and so forth. Think about it: which is easier for a beginner to create:
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}Or
using System;
using System.Windows.Forms;namespace HelloWorldForms
{
/// /// Main form for application
///
public partial class FrmMain : Form
{
#region Constants
#endregion#region Fields #region Internal #endregion #region Property bases #endregion #endregion #region Properties #endregion #region Regular Expressions #endregion #region Enums #endregion #region Constructors /// /// Default constructor /// public FrmMain() => InitializeComponent(); #endregion #region Events #region Event Constructors #endregion #region Event Handlers #region Form /// /// Restore size and location (if the user doesn't /// override it) /// /// /// private void FrmMain\_Load(object sender, EventArgs e) { if ((ModifierKeys & Keys.Shift) == 0) { this.LoadLocation(); } } /// /// Save the size and location (if the used doesn't /// override it) /// /// /// private void FrmMain\_FormClosing(object sender, FormClosingEventArgs e) { if ((ModifierKeys &
-
Well... I have been teaching programming novices to put a "Hello World" message box on the screen in a small fraction of all that red tape. I see the point you want to make, and you make it with true grandeur. But that is the only alternative.
You can do, yes - because VS with link all the stuff up for you and throw in a pile of code ready to rock and roll. But ... it looks like a lot of code to a beginner (because it is) and it's remarkably easy to break it and have no idea where or how to fix it! :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
trønderen (@Member-8575121) said
Quote:
Is Windows Forms a requirement? A major part of C# GUI programming today is done with WPF, Windows Presentation Foundation.
If you do go down the WPF route have a look at "WPF 4.5 Unleashed" by Adam Nathan (Pearson ISBN 978-93-325-3603-6). I'm finding it quite digestible. I've also used Charles Petzold's "Programming Microsoft Windows with C#" (Microsoft ISBN 0-7356-1370-2 - although I have a very old copy) Some these books come in at a hefty price so also have a look at InformIT: The Trusted Technology Source for IT Pros and Developers[^]. I haven't used it in years but I had a colleague who swore by it.
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
I did a search on Amazon, under books. Amazon Book Search[^]. There appear to be quite a few. Some were older, but even those should get you started. There are a few author's that I've found to be good, mostly the top names, like Charles Petzold[^] and I've had several Murach's[^] and liked them very much. The linked Murach's work might be a good starter, it is 2015 but thats not terribly old. I'm sure digging through the links and reviews will find you something useful.
Jack of all trades, master of none, though often times better than master of one.
-
You can do, yes - because VS with link all the stuff up for you and throw in a pile of code ready to rock and roll. But ... it looks like a lot of code to a beginner (because it is) and it's remarkably easy to break it and have no idea where or how to fix it! :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Any development environment do things for you. When I went from Pascal to C, ages ago, I was puzzled by the compiler automatically doing the linking for me. It throws in all sorts of library functions as well. In principle, there is little difference to modern IDEs. I made a minimal GUI Hello World - not quite a one-liner, but not that far away:
using System.Windows;
namespace Hello {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}public void Terminate(object sender, RoutedEventArgs evtArg) { Application.Current.Shutdown(); }
}
}Note that all I had to write myself was
public void Terminate(object sender, RoutedEventArgs evtArg) { Application.Current.Shutdown(); }
- the rest was generated for me. Then comes the GUI elements:
- again, a of it lot generated. All I had to write myself was:
(I did modify the generated window size and title as well, but those are cosmetics and not required for Hello World functionality). So I had to write seven lines (when also counting the one with nothing but a closing brace) to create a GUI Hello World. It sure is more than
#include
int main() {
std::cout << "Hello World!";
return 0;
}But then, hitting F5 is far easier than invoking the C++ compiler from a CLI. My experience is that to make novices/students fascinated and eager to learn, you must help them to rapidly build something that has a resemblance to what they are used to see on the screen. At least 19 out of 20 have never ever realated to a CLI interface, but 20 out of 20 have seen windows, buttons, text fields
-
There are many books on C# these days but a lot of them are aimed at console programming and there is little if any information about Windows desktop form programming. Can someone please recommend a book that will give me more understanding on how to write Windows desktop form type programs (programs with buttons, textboxes etc). Brian
It's "data binding" that mystifies most; this book is about the best on the matter. [Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET](https://www.codeproject.com/Articles/13058/Data-Binding-with-Windows-Forms-2-0-Programming-Sm)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food