DataGridView_CellValidating Event firing twice in C#

Posted by admin on December 31, 2014

Just had this error when I used some validation example code from Microsoft. The form event handler might already be initialized in the Designer.cs code, so if you are running the validation code in another class file, a lot of examples (like the Microsoft one) will confuse the issue by initializing the event handler again with something like this:

this.Load += new EventHandler(MyForm_Load);

So make sure there's only one EventHandler form load event per form, or else you'll get double error messages for each validation failure.


0 Comments Read full post »


Posted by admin on December 29, 2014

I dug around a lot trying to find out how to set a default value in the DataGridView ComboBox data field. There are two ways you can do this:

1) Right click on the datagridview object in the [Design] view of visual studio

2) Select Edit columns

3) Select your combobox

4) Select DefaultCellStyle in the properties window on the right

5) Select the little three periods next to the DataGridViewCellStyle box

6) Another box pops up, and says CellStyle Builder. Go down to Data where it says NullValue and put in your default value like MyDefaultValue

This should be the value that will show up in the box when populating the datagrid if there is nothing in that field.

Or, you can use this command in the Form.Designer.cs file:

dataGridViewCellStyleX.NullValue = "myDefaultValue";

where the X in X.NullValue is the field number in the DataGridView. If your combobox is the 1st field then you would write 

dataGridViewCellStyle0.NullValue = "myDefaultValue";

If it's the second field:

dataGridViewCellStyle1.NullValue = "myDefaultValue";

And so forth.



0 Comments Read full post »

Replace Windows 8 with Windows 7

Posted by admin on December 22, 2014

Here's the article I just used to replace Windows 8 with Windows 7:

How to uninstall Windows 8, install Windows 7 on Your PC

Some notes, your Bios changes will probably be different, I had to go into the advances settings and change my boot up mode from UEFI to CMS because there was no legacy setting, this seemed to work. Also, the Windows 7 compatability tool didn't find all the drivers I needed for installation, however when I went to Driverpack's webpage and installed the free version of driverpack, all the drivers for the new OS came up and installed fine, except for some keyboard drivers from Microsoft that hung on installation, but I didn't really need them.


0 Comments Read full post »

I went through a lot of crap before I figured this one out. Many of the forums that I went through had solutions where registry settings needed to be changed, and internet connection sharing needed to be turned off. None of that worked for me.

I finally figured out that I was using client version 3.0. This version allowed me to initially connect to the vpn server, but after the connection handshake something always went wrong. The 3.0 anyconnect client was given to me by my customer, but their server was really only compatable with a 3.1 version if it was running on a new version of Windows 7. Complicated huh?

Cisco won't allow you to download a 3.1 client unless you're a customer, but there are many places on Google that have it. Anyway, once I upgraded to 3.1, the problem went away.


0 Comments Read full post »

Irrigation Valve Repair

Posted by admin on July 22, 2014

So we came home from San Diego after being there for a week, and saw that our front yard had turned into a national park with geysers sprouting everywhere. At first I just thought some drip valve heads had popped off, so I replaced those right away. 

When my wife went out the next morning, one of the heads had popped off again. That's odd, why is the system still on? It's still on because the damn valve had blown. So I figured it was the solenoid over the valve, and I had an extra one and replaced it. No dice, the valve was still stuck on, and I couldn't turn it off. What the hell?

I called a repair guy and he said they couldn't come out for a couple of days and it would probably be $200. So I told them I'd call them back.

I took apart the irrigation valve under the solenoid, after watching a youtube video on it. I examined the diaphagm carefully, and noticed that it was perforated. Bingo!

Went down to the local irrigation store and bought another diaphragm for $13. So, if you have the same problem, and you own a screwdriver (cause that's all it took to fix) and $13 I highly recommend you try doing the same, it will save you $200. Make sure no debris gets into the valve when you take it apart.



0 Comments Read full post »

Knoppix HD Install on VMWare

Posted by admin on May 13, 2014

Some peculiar details on installing Knoppix 7.0 on VMWare


1) When configuring the vm, you must custom configure the hard drive type to IDE, or else the boot will hang

2) Tthe partition auto configure doesn't work right, you need to make at least two partitions, with gparted. One a swap partition with five gigs for swap memory. The rule of thumb for swap size is 2x the size of the ram you are using. Format as swap-linux. 

3) Set up a second partition for root. I used thirty-five gigs, but I'm using a portable hard drive for the vm so you may not want to part that much.The root partition needs to be formatted as reiserfs before Knoppoxwill agree to install it.

4) Close the Gparted screen and Knoppix should stop complaining. Follow the rest of the defaults, including installing a grub loader on mbr.

If you have a better way to do this, then you shouldn't even be here. Just kidding, leave a note in the comments, and I'll put it in here. A better way isn't you trolling tech boards and telling people to read the docs. If you do this (and you know who you are) I suggest you move out of mommy's basement, stop drinking wine and change to whisky, and join a fight club or something.

0 Comments Read full post »

I have a A&A Low profile infloor pool cleaning valve, and noticed while I was cleaning the pool today that the pool nozzles were stuck in one position, and the pool was filthy. I looked through the clear plastic cover of the valve and noticed that the wheel assembly was turning in the current from the pool pump like it should, but the gear assembly wasn't. The gear assembly turns a wheel at the bottom of the valve, and this wheel rotates around and lifts up these T-valves one by one, and pressured water flows to each infloor cleaning head, rotating pressured water around the pool.

I had to disassemble the valve before when an incompetent boob of a leak detector plumber broke it last year. And he didn't figure out where the leaks were, but enough about him. The gear assemble in the valve is a cheap plastic set of compound gears that turn the assembly. When I examined the gear assembly and tested it for functionality, I noticed that the smaller compound gears were worn away on the fourth gears, on both sides. The fact that both of them were damaged indicates a design flaw, although the whole thing was so cheaply made, it's hard to label anything on it a 'design flaw.'



The valve replacement cost is over $300, and the gear assembly replacement with shipping over $119. For a cheap set of plastic gears that probably cost about 20 cents a piece, this is theivery, pure and simple. And they don't sell the compound gears seperately, of course. Why would they? They can juice you for a least a hundred bones for this piece of garbage.

As I started to take some measurements to cast my own gear in polymer, with a kit, I noticed that they used five compound gears on each side. But only four of the gears used both large and small components of the compound gears. The outer gears don't use the smaller componants of the compound gear. But in their quest to be cheap-asses, A&A decided that they would use the same gear for all five. 

So the solution was, disassmble the gear mechanism using needlenose pliers to remove the snap washers carefully. Swap the outer, and position four compound gears, so the worn out smaller gears are in the outer position. Notice that the snap washers allow a little play in the gears, and position three gears have no snap washers. Now the worn out smallers are in the outer position where they aren't being used.

0 Comments Read full post »

Convert SAS Datetime to [R] Datetime

Posted by admin on March 24, 2014

Suppose I import a bunch of SAS dates into R. How well does that work?

Not very. First is the import itself. If you use read.csv, R will try to import the datetime field as factors, which creates a big ol mess. Let's fix that first. When you use read.csv, remember to include this phrase:



in the read.csv function as a parameter. That will import the SAS datetime field as a string. OK, now lets do our conversion:


datetime.field=strptime(SAS_DATE_TIME, "%d%b%Y:%H:%M:%S.%s")

And you're done. Problem solved.



0 Comments Read full post »

My Windows 7 laptop went haywire this morning, suddenly unrecognizing my USB devices. A short googling of the problem showed it wasn't uncommon. The solution was quite easy, and worked:


Unplug the power supply from the laptop and reboot.

That's it. Don't reinstall a bunch of drivers, reinstall your operating system, or any other craziness. Try this first.

1 Comment Read full post »

So I decided to make this web application that a user could create a legal form in Microsoft Word (docx) format, and since my web site is in PHP, and I wanted to learn PHP better. Just a few issues:

1) PHP can't make a Word - .docx document easily. Sure, you can do your bits and bytes and try to decode the entire format. Docx is just an archive, and you can zip up the components, but then you can't get your compression ratio right, and Word tells you the document is malformed when your browser calls it and blah-blah fricken blah. 

OK, so I figure, Java has libraries to do this, and do it easily. So I'll just make a Java program that will take the form data from the PHP generated form and make the docx. No problem at all, did this in a few hours with no knowledge of the java library that I used (docx4j). 

OK, so I jar up the program, make a properties file for paths and so forth, and deploy said jar to the Apache server on a windows system where I'm developing. Now, all I gotta do, is call the Java program from the php.


Calling a java program from php over the host operating system is about as easy as calling the international space station from a tin can with a string on it. To make it worse, I have to deploy on a Linux system making whatever Windows solution I come up with totally worthless. Now I find out about JavaBridge, which my zend php server tells me that it doesn't like, or home made solutions by changing the apache configuration settings which blows up apache and blah blah fricken blah.

OK, then it came to me. Talking to java over the operating system, isn't the only way to talk to java. You can talk to java through the file system. How? Just add a java listener to your java program, leave a marker on the file system from php...a text file with the docx's id number which I had already set up. Have the java listener make the docx, have the php sleep until it sees it. Bada bing bada bang...we have our solution. I wrote the listener in under an hour from scatch. Clean up by deleting the files with a sweep utility after generation. Works faster that any other way too.




13 Comments Read full post »