Created my first Windows Form Application

I’m a Linux guy. I haven’t used Windows in over 6 years now.

But, as part of my job description, I’ve started working on C#. For practice, I decided to check out what Windows Form Applications are all about. So I went ahead and did two things.

  • Created this Form with just 2 buttons, which would either throw up a MessageBox saying “Hello” or Exit the application. (Code snippets to follow)
  • Created another Form with a CheckBox List with numbers from 0 to 9, each of which when checked, would throw a MessageBox printing the number that was just checked. (What I intended to do was that the checked boxes would all be echoed onto the MessageBox as a list upon a ButtonPress event — haven’t gotten around to doing that yet, obviously. Maybe tomorrow)
  • So, here are the corresponding relevant code snippets — These amateurish notes are just that — notes, for my future reference. There. Disclaimer has been ..disclaimed.
private void button1_Click(object sender, EventArgs e)

The above snippet basically ties the showing up of the MessageBox with the click of button1.

private void button2_Click(object sender, EventArgs e)

When button2 is clicked, the Application is closed/exit.

this.button2.Click += new System.EventHandler(this.button2_Click);

Elaborating on the previous point, when button2 is clicked, button2_Click function is called and the underlying definition is executed, which here, is the exiting of the Application.

private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
if (checkedListBox1.GetItemChecked(0)) MessageBox.Show(“1”);
if (checkedListBox1.GetItemChecked(1)) MessageBox.Show(“2”);

This last piece throws the aforementioned MessageBox with the checked number when the corresponding box is checked — as soon as it’s checked actually. Not cool from a UX perspective.

The “Hello” Message on Pressing “Go”
“2” being displayed on checking ..”2"

Oh, and I also tried out the Advanced Installer. Packaged in this Release build (.exe) application and tried to install it. Not sure how to use it yet. Need to learn that tomorrow.

So, that’s how I started learning Windows Forms. Let’s see if I can build something actually useful in the next couple of weeks.