Wednesday, August 19, 2009

Checking a CheckBox in DatagridViewCheckboxColumn from code

I had a situation with a DatagridViewCheckboxColumn where I had to check a checkbox based on some conditions when the user initiates a click. Normally you would do that by setting the value of the column to true.
ex: gridView[e.ColumnIndex, e.RowIndex].Value = true;

But this code wans't updating the UI untill I clicked elsewhere on the grid or any other control. I tried using Invalidate, refresh etc. and nothing worked. Turns out as long as the current cell for the grid is assigned the UI will not get updated. So I got the whole thing to working by setting the CurrentCell to null.
Ex: gridView.CurrentCell = null;

Friday, August 14, 2009

unable to load dll 'sqlserverspatial.dll'

I was trying to move my .Net SqlServer 2008 to another dev machine and I kept getting this error, even thought I have the SqlServerSpatial.dll file in my bin. If you are getting the same error, do the following:

1. Make sure the SqlServerSpatial.dll file is in the bin of the application (you can find this dll on the machine that you have SqlServer2008 installed in the C:\Windows\System32 folder)
2. Make sure you have the latest VC++ redistributables installed. Turns out SqlServerSpatial.dll relies on VC++. You can download these redistributables for 32 bit (here) and 64 bit (here).
3. If you are still getting the error even after doing the above two, try running the SqlServer types installer to register the dll's with GAC.