Open a .cs file in code view instead of winforms designer

This bugged me for a while. It didn’t bug me enough to spend much time looking for it, but every once in a while I would give it a try and then I’d give up again. The problem? When double-clicking a file in the solution explorer, it would open in the windows forms designer. I wanted it to open in code view, but couldn’t find it anywhere in the extensive Visual Studio Options screen. For HTML-view, there was an option, but not for windows forms files. Huh?

That was because I was looking in the wrong place. Right click a .cs file and choose “Open with”. Then select “CSharp editor” and click “Set default”. Duh.

The easy-to-find option, in a really obvious place

Select all text in a textbox when the user clicks to focus

A tiny patch of code can sometimes save your users a lot of time. In a project I was working on, I used a lot of small textboxes to have the user input small numeric values. (Actually the textbox was a part of a kind of self-constructed NumericUpDown, but that’s another story.) Watching a tester work with the program, I saw him often clicking in the box and then starting typing his numbers, becoming increasingly annoyed that the numbers would be inserted at the position he clicked instead of overwriting the number that was already there.

Selecting all text in a box is nice behavior when you Tab into it, but in general I don’t like it for clicking in the box, because I expect the caret to be where I put it. There are exceptions to that: the browser address bar is one of them and that makes sense, because you more often than not want to overwrite the entire address instead of inserting or modifying parts. And, come to think about it, because these were just small numbers (up to 4 positions), I had to agree with the tester that it if you want to change a number, it would be a lot easier to just type over it, than it would be to start inserting or modifying digits. Lees meer over dit bericht