Dealing with the System.Windows.Forms.NumericUpDown

Tuesday, June 27, 2006
I ran into quite an annoying little .Net framework bug today. At least, I'm assuming it's a bug since I didn't notice any documentation explaining.

When I set the Minimum and Maximum values, you'd think that you wouldn't be able to enter a value outside that range, right? So would I. Unfortunately, it doesn't work out that way.. at least not at first.

Apparently, there is a bug in the events of the NumericUpDown control that prevent limiting or restricting the user input when done via the keyboard. The only way I could get the control to not allow letters into the field was by implementing two of its events. Implementing more than these two seems fine, but these two must be there together or it doesn't work.

What you do in the events does not matter if you at least access the e.KeyValue and numericUpDown.Value values within each event. That's all it took to get my code working.

private void numericUpDown_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
string fixdotnet = string.Format("numericUpDown_KeyDown {0}, {1}", e.KeyValue, numericUpDown.Value);
}

private void numericUpDown_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
string fixdotnet= string.Format("numericUpDown_KeyUp {0}, {1}", e.KeyValue, numericUpDown.Value);
}

Another interesting tidbit is that the Validating event would not fire AT ALL, unless I accessed the numericUpDown.Value field. Now, that's annoying.

I've cleaned the source up, created sample projects, removed/added/re-added controls, and closed Visual Studio .Net 2003 and tried again. Nothing seems to fix it.. Anyone have any ideas other than this workaround?

CVS commands

I usually just use TortoiseCVS when working by hand and csbatch files for automation. I generally don't use the command-line anymore. But, when I'm configuring a new module, setting up new files that I need to get often I always seem to forget the little details about CVS commands.

So, I go looking for a quick reference. I should create my own, maybe I will. For now, I found this great reference here: http://www.cs.ucsb.edu/~acha/courses/99/fall/cvs.html.

CSBatch, a C#-based Windows Batch file preprocessor

It seems that I use batch files for everything these days. Whether I'm copying executables and dll's to a test server or creating efficient builds, batch files are a main stable that won’t go away anytime soon. Yes, even after spending over a year creating new and updating existing NAnt scripts I still prefer using batch files for anything other than very large build scripts. And to be honest it still probably isn’t worth it. Especially since I created csbatch.

CSBatch is a batch file preprocessor of sorts. It allows me to create a .csbat file, associate it with my csbatch.exe, and add new commands to the standard set of batch file commands. For instance, I can create functions and if else statements that include more than one line of code.

Probably one of the best things is that the .csbat file is parsed (on the fly) into a standard .bat file that will run on any Windows machine, without the need for the csbatch.exe executable. That’s cool!

Anyway, for more information check out my website at: http://www.wasatchwizard.com/downloads/CSBatch.aspx.

FolderExists()

Monday, June 26, 2006
I haven't found a good method to check if a folder exists in non-managed C++, so I thought I'd post what I came up with. This also works with Windows CE, too.

bool FolderExists(TCHAR *szPath)
{
DWORD dwAttr = GetFileAttributes(szPath);
if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
{
return TRUE;
}
return FALSE;
}


Bear in mind, however, that this could also return false if there was a permissions error. I'll let you expand upon it as like.

Blog websites: Only show me unread posts

Monday, June 12, 2006
It would be very cool to have a blogger website that provides user accounts (for free of course, or maybe not) that allow you to read through their posts and mark each one as read when finished. This is very similar if not identical to how WebGator Online works - only I want to see the author’s colors, theme, etc.

There are several benefits to this being part of the blog website itself, not to detract from WGO.

My biggest reason for wanting this is that when I go to Scobleizer’s blog, for instance, I would only see the posts that I haven’t read yet. That’d be cool. I could still view his homepage/blog site from within my choice of aggregator such as NewsGator Online. But, now it would have his theme, his environment.

Why bother? Well, for me I feel like I get more from the blogs I read when they are surrounded by the author’s design choices, including font, colors, images, style, etc. I think the real difference is this: instead of having the news read to me by a monotonous reporter, the person making the news gives it to me directly in all of their flare. When I read blogs in a plain’ol viewer like Outlook (including 2007) and other plain-vanilla readers each blog is presented in black and white, same for each, with less expression. When viewed on the author’s site it is presented in full color in the way the author wants you to see it.

This could be as simple as setting a cookie on my browser to show only newer items or as detailed as creating a free user account with the blog site. A way to re-use your existing account(s) on blogger and the like would be very nice.

DevReadiness.org

Wednesday, June 7, 2006
I found this great resource for Windows Presentation Foundation (Avalon) development. I don't know how I missed this over the last couple of months..

"Welcome to DevReadiness.org - the community site dedicated to helping you, the developer, get your application ready for new the Microsoft platform. Here you will find the technical information needed to help get your applications to interoperate with Windows Vista today. Get ahead of the building customer demand for the next generation of Windows platform."

http://devreadiness.org/default.aspx

C# desktop programming assessment

Thursday, June 1, 2006

I took the free Microsoft® Windows®-based Client Development with Microsoft Visual Studio® 2005 and Microsoft Visual C#® assessment exam online today during lunch. There were a couple of areas that I wasn't familar with so I guestimated. I got highest score, too, which was surprising!? I think 73% is a passing grade for the MCSD exams. Maybe I should go get certified?

http://assessment.learning.microsoft.com/test/home.asp#15
Older Posts Home Newer Posts