Click here to Skip to main content

Articles by OriginalGriff (Articles: 5, Tip/Tricks: 48)

Articles: 5, Tip/Tricks: 48

RSS Feed

Average article rating: 4.87

Miscellaneous

A multi-selection Drop Down List using a generic Abstract PopUp class
Posted: 10 Jun 2012   Updated: 10 Jun 2012   Views: 5,908   Rating: 4.91/5    Votes: 5   Popularity: 3.41
Licence: The Code Project Open License (CPOL)      Bookmarked: 7   Downloaded: 208
A Generic Abstract class providing a true Pop-up control, implemented in a multiple selection drop down list.

C#

A Simple Code Snippet to Add an Event
Posted: 8 Jun 2012   Updated: 8 Jun 2012   Views: 3,991   Rating: 4.76/5    Votes: 10   Popularity: 4.75
Licence: The Code Project Open License (CPOL)      Bookmarked: 9   Downloaded: 64
Adding an event to your class is simple, but it needs a bit of typing. I'm lazy, so I'd rather Visual Studio did the work. This snippet works in the same way as the "prop" snippet.

Date and Time

DateTime Extensions to Make Some Simple Tasks a Little More Readable
Posted: 9 Mar 2012   Updated: 6 Jun 2012   Views: 7,154   Rating: 4.75/5    Votes: 6   Popularity: 3.89
Licence: The Code Project Open License (CPOL)      Bookmarked: 12   Downloaded: 0
Sometimes, you want to insert a date into a database as the start of the day, or you need to work out when the last Tuesday of the month is. These aren't difficult tasks, but the code can be difficult to follow. These extensions provide an easy-to-read way to do it.

DLLs & Assemblies

Timestamping assemblies with Build date and time.
Posted: 27 Apr 2012   Updated: 27 Apr 2012   Views: 6,935   Rating: 4.95/5    Votes: 7   Popularity: 4.18
Licence: The Code Project Open License (CPOL)      Bookmarked: 17   Downloaded: 138
It surprised me to find that there is no simple way to find out when a .NET assembly was built. You can work it out from the revision number (provided you only use the "standard" numbering scheme) but it's not obvious. This provides a simple way to timestamp individual assemblies at build time.

Interviews

A Coder Interview With Paul Griffin
Posted: 21 Sep 2011   Updated: 21 Sep 2011   Views: 16,894   Rating: 4.96/5    Votes: 43   Popularity: 8.09
Licence: The Code Project Open License (CPOL)      Bookmarked: 9   Downloaded: 0
Welcome to our continuing series of Code Project interviews in which we talk to developers about their backgrounds, projects, interests and pet peeves. In this installment we track down Code Project member Paul Griffin.
No blogs have been submitted.

Average tips rating: 4.84

Dialogs and Windows

Save and restore your form size and location [Tip/Trick]
Posted: 10 Feb 2013   Updated: 11 Feb 2013   Rating: 4.88/5    Votes: 8   Popularity: 4.52
Licence: The Code Project Open License (CPOL)      Bookmarked: 13   Downloaded: 0
It's one of those things that annoys me - and probably you - you set up five or so windows so they are in the right place on your desktop, and it lovely. Then you open them again tomorrow...and one of them always opens too big, and in the middle of the screen...

Files and Folders

Where should I store my data? [Tip/Trick]
Posted: 20 Apr 2012   Updated: 20 Apr 2012   Rating: 5.00/5    Votes: 6   Popularity: 3.89
Licence: The Code Project Open License (CPOL)      Bookmarked: 16   Downloaded: 0
There is a common theme in development: storing data files in the application folder. This is bad, and wrong, and should be stamped on!

Miscellaneous

On-demand loading of images from a database [Tip/Trick]
Posted: 16 May 2012   Updated: 16 May 2012   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 6   Downloaded: 0
Loading an image from a database isn't difficult, but it can waste time. If you are loading a large list of Images (or even thumbnails) from a DB but not using them immediately, then it can take some considerable time. Why not load them on demand instead?
Transferring information between two forms, Part 1: Parent to Child [Tip/Trick]
Posted: 19 Feb 2013   Updated: 3 Apr 2013   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 8   Downloaded: 65
Questions here quite often ask "how do I send data from one form to another?" and I must have answered this a dozen times. So, a series of three tips to cover the process.
Transferring information between two forms, Part 3: Child to Child [Tip/Trick]
Posted: 18 Feb 2013   Updated: 3 Apr 2013   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 10   Downloaded: 92
Questions here quite often ask "how do I send data from one form to another?" and I must have answered this a dozen times. So, a series of three tips to cover the process.
Transferring information between two forms, Part 2: Child to Parent [Tip/Trick]
Posted: 18 Feb 2013   Updated: 3 Apr 2013   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 8   Downloaded: 79
Questions here quite often ask "how do I send data from one form to another?" and I must have answered this a dozen times. So, a series of three tips to cover the process.

ASP.NET

Supporting Development and Release web.config in ASP.NET [Tip/Trick]
Posted: 5 Jan 2011   Updated: 7 Jan 2011   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 8   Downloaded: 0
Supporting Development and Release web.config in ASP.NET
Showing a page of information at a time in a GridView [Tip/Trick]
Posted: 7 Feb 2011   Updated: 8 Feb 2011   Rating: 4.83/5    Votes: 8   Popularity: 4.36
Licence: The Code Project Open License (CPOL)      Bookmarked: 6   Downloaded: 0
When I add a log reader, the size of the log can be huge, and get very slow to view. This makes the GridView do all the work of paging the data for you.
A generic Image-From-DB class for ASP.NET [Tip/Trick]
Posted: 14 Aug 2011   Updated: 14 Aug 2011   Rating: 4.75/5    Votes: 4   Popularity: 2.81
Licence: The Code Project Open License (CPOL)      Bookmarked: 6   Downloaded: 0
Getting an image from a database and displaying it in an ASP.NET page is something we have to do quite often. Here is a generic class which does the job for you.

Android

Eclipse Protocol Error when Updating, or Installing ADT [Tip/Trick]
Posted: 10 Oct 2012   Updated: 10 Oct 2012   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
If you are trying to follow the instructions on how to get your system up and running with Eclipse, you may get an error when installing ADT

Database

Multiple SQL INSERT Operations with a Single Command [Tip/Trick]
Posted: 23 Sep 2012   Updated: 23 Sep 2012   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 6   Downloaded: 0
Inserting a number of rows in a database isn't difficult, but how do you do it in a single command without concatenating strings?
Why do I get a "Parameter is not valid." exception when I read an image from my database? [Tip/Trick]
Posted: 26 Sep 2012   Updated: 27 Sep 2012   Rating: 4.92/5    Votes: 5   Popularity: 3.32
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 0
Why? Normally, it's because you stored it wrong...
Backing up an SQL Database in C# [Tip/Trick]
Posted: 18 Sep 2012   Updated: 18 Sep 2012   Rating: 4.95/5    Votes: 12   Popularity: 5.34
Licence: The Code Project Open License (CPOL)      Bookmarked: 20   Downloaded: 904
One of the things that it seems far to hard to find is a reliable way of backing up a database, and restoring it again later. Particularly for development, where the SQL server instance and the database are likely to be on your development machine, and very likely to be damaged by code.
Using comma separated value parameter strings in SQL IN clauses [Tip/Trick]
Posted: 27 Apr 2013   Updated: 7 May 2013   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: The Code Project Open License (CPOL)      Bookmarked: 6   Downloaded: 17
Passing a comma separated list of values to an SQL query is all very well, but you can't just use them in an "IN" clause. This helps.

C#

Removing Diacritics from Strings [Tip/Trick]
Posted: 25 Jun 2012   Updated: 25 Jun 2012   Rating: 4.80/5    Votes: 5   Popularity: 3.32
Licence: The Code Project Open License (CPOL)      Bookmarked: 9   Downloaded: 61
When you search for matching substrings, you may have noticed that Google matches accented characters to unaccented. If you are searching strings which may contain accented characters, you should consider doing the same.
Hiding inherited properties [Tip/Trick]
Posted: 1 Feb 2010   Updated: 2 Oct 2011   Rating: 4.76/5    Votes: 24   Popularity: 6.57
Licence: The Code Project Open License (CPOL)      Bookmarked: 7   Downloaded: 0
When you create a custom control (or any class), you inherit a lot of properties from the base class, most of which are fine. However, particularly in the case of a control derived from UserControl this brings a lot of properties which may not be relevant to the new control.
A C# implementation of AI MEMO 239, Item 169- Count the one bits in a number [Tip/Trick]
Posted: 12 Apr 2012   Updated: 12 Apr 2012   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
If you haven't heard of AI Memo 239, then you need to have a look at it. It is an MIT memo from 1972 containing "clever code" and such like. Some of it is absolutely beautiful!
Extension methods for finding centers of a rectangle [Tip/Trick]
Posted: 13 Jun 2012   Updated: 13 Jun 2012   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 23
It's very easy to work out the center of a rectangle, but it's messy as inline code. Hence these simple extension methods to provide the five centers.
Converting a value to an SI unit string [Tip/Trick]
Posted: 2 Jul 2012   Updated: 2 Jul 2012   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 24
Converting a value to an SI unit string.
Making an overridden Text property visible in the Visual Studio designer for a UserControl [Tip/Trick]
Posted: 14 Jun 2012   Updated: 14 Jun 2012   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 0
Having the property "Text" be available for almost everything in .NET that interacts with the user makes life very simple. But when you create a new UserControl, the Text property doesn't appear in the Properties pane.

.NET Framework

A safe way to get the user to check if the .NET framework is installed [Tip/Trick]
Posted: 28 Apr 2011   Updated: 29 Apr 2011   Rating: 4.50/5    Votes: 6   Popularity: 3.50
Licence: The Code Project Open License (CPOL)      Bookmarked: 9   Downloaded: 0
Sometimes, it is helpful to find out if the .NET framework is installed on a machine, or get a user to check over the phone. But, some people should not be allowed near Regedit or the windows folder, so here is a safe way to get them to check.
DateTime Extension Method to Give Week Number [Tip/Trick]
Posted: 14 Jul 2011   Updated: 14 Jul 2011   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: The Code Project Open License (CPOL)      Bookmarked: 5   Downloaded: 0
Strangely, the .NET DateTime does not provide a Week Number. This extension rectifies this.
Converting a List to a DataTable [Tip/Trick]
Posted: 15 Jul 2011   Updated: 18 Jul 2011   Rating: 4.97/5    Votes: 17   Popularity: 6.11
Licence: The Code Project Open License (CPOL)      Bookmarked: 16   Downloaded: 0
I wrote this because I was interested in a Q&A question which asked for exactly that. Since I quite often use DataTables to transfer data, and to display it for debugging I knocked up an extension method to do it.
Counting Lines in a String [Tip/Trick]
Posted: 9 Jan 2012   Updated: 18 Jun 2012   Rating: 4.84/5    Votes: 27   Popularity: 6.92
Licence: The Code Project Open License (CPOL)      Bookmarked: 27   Downloaded: 86
It seems like an obvious requirement, but the .NET framework will not count occurrences of a character in a string. It's easy to do, but which way is the quickest?
Working with Age: it's not the same as a TimeSpan! [Tip/Trick]
Posted: 30 Mar 2013   Updated: 30 Mar 2013   Rating: 5.00/5    Votes: 6   Popularity: 3.89
Licence: The Code Project Open License (CPOL)      Bookmarked: 11   Downloaded: 58
Working with an Age (as in a persons age) is not the same as a Timespan, and there is no simple way to return an age. This provides a class to solve this.

Internet / Network

Retrieving IP and MAC addresses for a LAN [Tip/Trick]
Posted: 2 Apr 2012   Updated: 2 Apr 2012   Rating: 4.14/5    Votes: 6   Popularity: 3.24
Licence: The Code Project Open License (CPOL)      Bookmarked: 11   Downloaded: 0
Getting the IP and MAC for your PC is pretty simple, but what if you need those on your local network? It's not as simple as it sounds...

Macros and Add-ins

Making F1 do something useful in Visual Studio [Tip/Trick]
Posted: 10 Feb 2011   Updated: 12 Feb 2011   Rating: 5.00/5    Votes: 49   Popularity: 8.45
Licence: The Code Project Open License (CPOL)      Bookmarked: 30   Downloaded: 0
F1 in Visual Studio takes forever, and rarely comes up with anything useful. Replace it with a Google MSDN search!

Programming Tips

Visual Studio Tasks List [Tip/Trick]
Posted: 5 Jul 2010   Updated: 5 Jul 2010   Rating: 5.00/5    Votes: 14   Popularity: 5.73
Licence: The Code Project Open License (CPOL)      Bookmarked: 7   Downloaded: 0
Marking code you need to return to later
Following object inheritance [Tip/Trick]
Posted: 20 Jul 2010   Updated: 23 Jul 2010   Rating: 4.29/5    Votes: 7   Popularity: 3.62
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
Sometimes, it helps to know the complete inheritance of an object or type in order to understand what can be done with it. This Tip presents a simple C# class to access the information
Human readable strings for enum elements [Tip/Trick]
Posted: 12 Aug 2010   Updated: 12 Aug 2010   Rating: 4.78/5    Votes: 8   Popularity: 4.26
Licence: The Code Project Open License (CPOL)      Bookmarked: 9   Downloaded: 0
Using enum really helps readability, but the values within the enum must understandably conform to the rules for variables names. This is fine until you need to display enum values to the user. This tip shows you how to associate and access a human readable string with each enum element.
Converting dates to the Roman equivalent [Tip/Trick]
Posted: 26 Aug 2010   Updated: 26 Aug 2010   Rating: 4.67/5    Votes: 3   Popularity: 2.23
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
If your tutor asks you to convert years to the Roman equivalent, (e.g. 2010 to MMX) then you are not alone! Here is the simplest, most foolproof way to do it!
Getting the last error in a custom error page [Tip/Trick]
Posted: 3 Jan 2011   Updated: 5 Jan 2011   Rating: 4.33/5    Votes: 3   Popularity: 2.07
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 0
When you provide a custom error handler page, it is useful to be able to log what caused the problem, so that you can fix it. Server.GetLastError() will not return anything in the page, though...
Sending an Email in C# with or without attachments: generic routine. [Tip/Trick]
Posted: 2 Mar 2011   Updated: 3 Mar 2011   Rating: 4.90/5    Votes: 38   Popularity: 7.73
Licence: The Code Project Open License (CPOL)      Bookmarked: 39   Downloaded: 0
Sending an email is not a real problem, but I am fed up with answering the question "How do I do it?" in Q&A . So, here is the generic routine I use to send an email, with or without attachments, so I can just point people at it!
Password Storage: How to do it. [Tip/Trick]
Posted: 25 Apr 2011   Updated: 29 Apr 2011   Rating: 4.87/5    Votes: 72   Popularity: 9.04
Licence: The Code Project Open License (CPOL)      Bookmarked: 81   Downloaded: 0
A lot of people are asking how to encrypt passwords, and I have answered "Don't do it" too many times. This Tip describes how to store a password in your database, and why.
Adding a File Open dialog to a PropertyGrid control [Tip/Trick]
Posted: 8 May 2011   Updated: 8 May 2011   Rating: 4.10/5    Votes: 9   Popularity: 3.82
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
The Visual Studio Property pane is a control, which can be used in WinForms like any other, and it provides a simple, easy to use property editor for your classes. However, it is not obvious how to get it to open a browse dialog for a file path property.
A simple way to ensure only one instance is running. [Tip/Trick]
Posted: 31 Jul 2011   Updated: 31 Jul 2011   Rating: 4.44/5    Votes: 7   Popularity: 3.70
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
Sometimes, you want to only run a single instance of an application - this makes it very simple to do. An Extension method that checks, switches and kills as necessary.
A FileDialog.Filter generator for all supported images [Tip/Trick]
Posted: 16 Sep 2011   Updated: 18 Sep 2011   Rating: 5.00/5    Votes: 6   Popularity: 3.89
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
Recently, I had to write a quick app to load images into a database, and wanted to restrict the file type to just images. You can do this with the OpenFileDialog.Filter property, but it is a pain working out what file extensions to permit.
Adding your items to Visual Studio default files [Tip/Trick]
Posted: 17 Jul 2010   Updated: 9 Oct 2011   Rating: 4.95/5    Votes: 16   Popularity: 5.96
Licence: The Code Project Open License (CPOL)      Bookmarked: 12   Downloaded: 0
Adding your items to Visual Studio default files
How to get a basic WCF service working on a web hosting service [Tip/Trick]
Posted: 10 Oct 2011   Updated: 10 Oct 2011   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
Originally, I was going to create a simple Web Service using an ASMX file, but that appears to have been removed from Visual Studio 2010 - or at least I couldn't find it easily. So, WCF it is! I love the way technology lasts, don't you? Right, so I know nothing about WCF, tutorials here I come...
Setting a default value for C# Auto-implemented properties [Tip/Trick]
Posted: 4 Jan 2012   Updated: 7 Jan 2012   Rating: 5.00/5    Votes: 12   Popularity: 5.20
Licence: The Code Project Open License (CPOL)      Bookmarked: 10   Downloaded: 0
One of the things missing from C# is the ability to set a default value of auto-implemented properties. You can set a default for variable backed properties, and you can set them for the designer. This does it for you.
XmlSerializer doesn't work with Dictionaries. Oh, and it has problems with KeyValuePairs too. [Tip/Trick]
Posted: 12 Jan 2012   Updated: 13 Jan 2012   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 0
XmlSerializer complains if you try to serialize anything which implements IDictionary. This provides a way of serialising them which (if not capable of restoring the exact dictionary content) restores the actual field contents in a new dictionary.
Using Visual Studio to find a database connection string [Tip/Trick]
Posted: 14 Jan 2012   Updated: 14 Jan 2012   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
Visual Studio has a Server Explorer built in to handle database access - it can lalso generate database connection strings ready for saving in application config files.
Using human readable enum values in a ComboBox [Tip/Trick]
Posted: 24 Jan 2012   Updated: 31 Jan 2012   Rating: 4.88/5    Votes: 13   Popularity: 5.43
Licence: The Code Project Open License (CPOL)      Bookmarked: 13   Downloaded: 0
Sometimes, all I want is a control which allows the user to select one of several options, and tell me which one - ideally as a handy enum value. This shows a simple method which allows this.
Converting numbers to the word equivalent. [Tip/Trick]
Posted: 19 Aug 2010   Updated: 12 May 2013   Rating: 4.95/5    Votes: 66   Popularity: 9.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 10   Downloaded: 0
If your tutor asks you to convert numbers to words (i.e. 565 to a string "Five hundred and sixty-five") then you are not alone! Here is the simplest, most foolproof way to do it.

Tools and IDE

Adding a Snippet to Visual Studio [Tip/Trick]
Posted: 16 Nov 2011   Updated: 20 Nov 2011   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: The Code Project Open License (CPOL)      Bookmarked: 5   Downloaded: 0
It is really easy to do once you get the idea how, but the Microsoft documentation could be a lot clearer - so here is a simple sample with full instructions.

Uncategorised Quick Answers

Formatting a DateTime for display - format string description [Tip/Trick]
Posted: 26 Jan 2010   Updated: 26 Jan 2010   Rating: 4.90/5    Votes: 9   Popularity: 4.67
Licence: The Code Project Open License (CPOL)      Bookmarked: 5   Downloaded: 0
Normally I keep information like this in a text file, in a folder called "How To Do It", as it is handy to have around, and too much work to search for each time I need it, but too much detail for me to remember if I don't use it often. Formatting a DateTime for display:DateTime.ToString()...
Disable the Close box on a form [Tip/Trick]
Posted: 26 Jan 2010   Updated: 18 Feb 2012   Rating: 4.93/5    Votes: 21   Popularity: 6.52
Licence: The Code Project Open License (CPOL)      Bookmarked: 13   Downloaded: 0
Disable the Close box on a form

Code Generation

Create Visual Studio forms for items you frequently use [Tip/Trick]
Posted: 8 Jan 2012   Updated: 8 Jan 2012   Rating: 4.63/5    Votes: 8   Popularity: 4.39
Licence: The Code Project Open License (CPOL)      Bookmarked: 7   Downloaded: 0
Quite often, when I create a new form, the first thing I need to add is an OK and a Cancel button. Recently, I realized that I could create templates for these in Visual Studio and save some time.

OriginalGriff
CEO
Wales Wales
Member
Born at an early age, he grew older. At the same time, his hair grew longer, and was tied up behind his head.
Has problems spelling the word "the".
Invented the portable cat-flap.
Currently, has not died yet. Or has he?


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 19 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid