DataGridView with an object data source

Posted by myself on September 04, 2010
For my Batch Replacer I am using a DataGridView with an object data source, meaning that I have a collection class that holds the data to be displayed. At first that class inherited from a usual List<T>, which led to the problem that the data binding wasn't two-way. As soon as I bound data to the DataGridView, it wasn't possible to add any new rows to it in my user interface. After some research I found out that instead of using a normal List<T> I was supposed to use a BindingList<T>. Using that the binding is two-way, and the user interface is normally editable and new rows can be added. Also, of course, all modifications done in the user interface are reflected in the object (meaning e.g. that when a new row is added, the object data source contains a corresponding entry).

Replace as in batch replace

Posted by myself on September 03, 2010

So I once again needed to replace several patterns in multiple files with something new... Instead of doing this all in my favorite text editor by using repeatedly find/replace, I decided that something more handy was needed. Of course I could have done all that replace stuff with xslt, but hey, who actually likes xslt.

The result of my disapproval of the above mentioned options is the Batch Replacer. As always it is released under the gpl. I also used git for the first time and published the source code on github.

Navigate to those... out of the box with firefox

Posted by myself on March 30, 2010

Ok well, this doesn' seem to be new at all, but nevertheless I missed that. Firefox has the great functionality to assign shortcuts to certain bookmarks and supply a parameter to the URL. This leads to really great quick searches (aka. the art of bookmarking).

What I have now are shortcuts to all my often used search sites. To search in wikipedia e.g. I type CTRL + L (shortcut for placing the cursor in the URL bar in firefox), then type wp asdf and there I go.

 

I guess this fact renders my previously posted quick link access tool obsolete...

Navigate to those URLs over and over again...

Posted by myself on May 15, 2009

I've written a tool that allows to define commonly used URLs for repeated access, varying only by a defined parameter-part. When you call one of those URLs, you just need to pass a parameter and it opens in the browser. That way you get quick access to often used URLs, e.g. your preffered search engine, your ticketing system or whatever. For even faster access the URLs are bound to predefined global hotkeys.

More infos can be found on the project page.

Screenshot of the main application's window

SharePoint list item and its ItemAdding event

Posted by myself on April 01, 2009

I've found many solutions and discussions trying to find one about the ItemAdding event for a SharePoint list item on the internet, neither of which fixed my problem. Actually I've had two. 

The first one was that you have to set the changes made to the ChangedProperties property that belongs the AfterProperties property. If you try to set them on the AfterProperties directly (why you can do this I don't know) the changes will be ignored when creating the item.

The second problem was that all values at the point of that event are stored as strings, they are not yet converted to their respective classes. In my case I needed to set the end date of an event list item 45 minutes after the event date. The following code snippets shows how to achive this. Basically you first have to convert the string into a DateTime object, add the 45 minutes to it and convert the DateTime object back to a valid string representation.


public override void ItemUpdating(SPItemEventProperties properties)
{
    base.ItemUpdating(properties);

    DateTime eventDate =
        SPUtility.CreateDateTimeFromISO8601DateTimeString(properties.AfterProperties["EventDate"].ToString());

    properties.AfterProperties.ChangedProperties["EndDate"] =
        eventDate.AddMinutes(45).ToString("o");
}

Nullable average in LINQ

Posted by myself on October 12, 2008

The following code is one possibility (there may be more elegant solutions to this) to handle a nullable average from a linq query. The problem arises when the linq query does not return a result, thus the average being null. If you don't use a nullable type, you'll get an exception. To get a nullable average from an integer value you'll need to provide a transform function to the Average funtion.


double? nullableAverage =
	(from m in dataContext.Moods
	 join g in dataContext.Groups on m.GroupGUID equals g.GUID
	 where g.GUID == groupGUID
	 select m.Level)
	.Average<int>(x => new double?(x));

int average = (int)Math.Round(nullableAverage.HasValue ? nullableAverage.Value : 0, 0);

// ...

  • 0 comments

  • Fatal error: Cannot redeclare getpagecooserlinkhtml() (previously declared in /home/www/web261/html/koffeinfrei5/modules/Blogs/action.showblog.php:11) in /home/www/web261/html/koffeinfrei5/modules/Blogs/action.showblog.php on line 11