The WinForms Notepad Project: Scrollbars, Plus More Status Bar and About Box (Premium)

After using NotePadWF extensively at Ignite 2019, I’m ready to make a few bug fixes and fit and finish improvements.
Scrollbars
I used our little Notepad clone pretty extensively during Ignite 2019 and, perhaps not surprisingly, I did find a few bugs. Some are related to the first-run experience, when you install the app on a new PC and it doesn’t behave as expected, but that will have to wait, since we’ll discuss publishing and installing at a later time. For now, let me focus on the bigger issue: the app’s lack of scrollbars.

If you’re familiar with Notepad, you know that it will display vertical and/or horizontal scrollbars when necessary; the former is a common occurrence with long documents and the latter happens a lot when you disable word wrap. But our Notepad clone does not display scrollbars at all. Oops.

Fortunately, it’s an easy fix: Display Form1.vb [Design], select TextBox1, and then locate the ScrollBars property (in the Properties pane). Change it from None to Both.
Status bar
I originally implemented the status bar fields in epically poor fashion by padding each field’s Text property with additional spaces. So let’s fix that. The goal is for each field to retain a static size and to not change as the application window or one of the field values (currently only the Zoom value) changes.

The first step is to remove the blank spaces we added at the end of each field’s Text property. Then, we need to set the AutoSize property of the four rightmost and non-empty fields to False. Remember, you can do that in one step by CTRL-clicking each field first. (Or, you can just do them one at a time.)

Next, we need to add a little bit of padding between the border line that sits to the left of each field and the first character that’s in its displayed text. This control supports both Padding and Margin properties, and it seems like at least one of these should do the trick. But I couldn’t figure it out, so my solution was to simply add a blank space to the Text property for each. (So, “ 100%” instead of “100%” for ZoomStripStatusLabel.) Surprisingly, this very closely mimics what Notepad looks like. But we also have to change some code that the zoom value displays correctly whenever it’s changed.

In RestoreDefaultZoomToolStripMenuItem_Click, we currently have a line of code that reads:
ZoomToolStripStatusLabel.Text = "100%"
This will need to be changed to:
ZoomToolStripStatusLabel.Text = " 100%"
And in FontToolStripMenuItem_Click, ZoomInToolStripMenuItem_Click, and ZoomOutToolStripMenuItem_Click, there is a line of code that reads:
ZoomToolStripStatusLabel.Text = (ZoomValue).ToString + "%"
This will need to be changed to the following in each:
ZoomToolStripStatusLabel.Text = " " + (ZoomValue).ToString + "%"
Finally, we need to set the Size.Width property of each status bar to a specific value. (Technically, Size is a property and Width is a structure value.) I used the following:

T...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC