Click here to Skip to main content
15,878,871 members

Articles by OriginalGriff (Articles: 20, Tip/Tricks: 94)

Articles: 20, Tip/Tricks: 94

RSS Feed

Average article rating: 4.77

All Topics
21 Sep 2011   Updated: 30 Apr 2014   Rating: 4.96/5    Votes: 76   Popularity: 9.25
Licence: CPOL    Views: 72,214     Bookmarked: 14   Downloaded: 0
Please Sign up or sign in to vote.
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.
Database Development
1 Dec 2022   Updated: 1 Dec 2022   Rating: 4.86/5    Votes: 16   Popularity: 5.58
Licence: CPOL    Views: 14,191     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
There are many things you can use to store information, but not all of them are databases. And trying to use them as such is a really, really bad idea.
General Programming
Printing
17 Sep 2019   Updated: 17 Sep 2019   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 8,971     Bookmarked: 7   Downloaded: 0
Please Sign up or sign in to vote.
OK, OK. I had to set it up - Herself insisted - and I had to actually print to be sure. So I knocked up a quick box to print (just to show I could).
25 Nov 2019   Updated: 25 Nov 2019   Rating: 4.64/5    Votes: 3   Popularity: 2.21
Licence: CPOL    Views: 5,675     Bookmarked: 1   Downloaded: 61
Please Sign up or sign in to vote.
So ... you want to put that LCD display in there, huh? Pity it's not a rectangular frame, isn't it? How are you going to fit a neat frame round that, huh? It's complicated, but ... not that complicated when you get used to it.
17 Sep 2019   Updated: 18 Jun 2021   Rating: 4.85/5    Votes: 12   Popularity: 4.85
Licence: CPOL    Views: 11,883     Bookmarked: 16   Downloaded: 0
Please Sign up or sign in to vote.
I'm getting a 3D printer for Christmas! So - I need to learn to use it. That means ... a CAD package. Gulp.
Mobile Apps
Android
28 Feb 2017   Updated: 28 Feb 2017   Rating: 5.00/5    Votes: 7   Popularity: 4.23
Licence: CPOL    Views: 20,302     Bookmarked: 2   Downloaded: 36
Please Sign up or sign in to vote.
The Nexus 7, the Amazon Fire 7 inch, and the Chuwi Hi12. A personal review.
Programming Languages
C#
4 Oct 2017   Updated: 4 Oct 2017   Rating: 4.83/5    Votes: 7   Popularity: 4.08
Licence: CPOL    Views: 12,391     Bookmarked: 7   Downloaded: 114
Please Sign up or sign in to vote.
We all know database connection strings and suchlike should not be hard coded - but then there is the problem of getting the right string into the right PC when you release software.
1 Oct 2019   Updated: 1 Oct 2019   Rating: 4.76/5    Votes: 5   Popularity: 3.33
Licence: CPOL    Views: 14,796     Bookmarked: 9   Downloaded: 235
Please Sign up or sign in to vote.
How to double click a file in explorer and add it to your app while it's running
10 Jun 2012   Updated: 10 Jun 2012   Rating: 4.92/5    Votes: 30   Popularity: 7.19
Licence: CPOL    Views: 32,072     Bookmarked: 19   Downloaded: 748
Please Sign up or sign in to vote.
A Generic Abstract class providing a true Pop-up control, implemented in a multiple selection drop down list.
8 Jun 2012   Updated: 8 Jun 2012   Rating: 4.98/5    Votes: 36   Popularity: 7.57
Licence: CPOL    Views: 37,665     Bookmarked: 14   Downloaded: 321
Please Sign up or sign in to vote.
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.
23 Feb 2014   Updated: 23 Feb 2014   Rating: 4.94/5    Votes: 139   Popularity: 10.57
Licence: CPOL    Views: 140,498     Bookmarked: 117   Downloaded: 0
Please Sign up or sign in to vote.
What is the difference between a struct and a class? And which should I use?
1 Feb 2015   Updated: 5 Mar 2015   Rating: 4.84/5    Votes: 127   Popularity: 9.81
Licence: CPOL    Views: 119,668     Bookmarked: 45   Downloaded: 0
Please Sign up or sign in to vote.
A .NET List is a list you can use as an array. Isn't it? Yeah, I'm sure it is. And I can use it anytime, can't I? Well, "No". And "No". Sometimes it's not a good idea at all.
9 Mar 2012   Updated: 6 Jun 2012   Rating: 4.92/5    Votes: 20   Popularity: 6.29
Licence: CPOL    Views: 36,285     Bookmarked: 19   Downloaded: 0
Please Sign up or sign in to vote.
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.
27 Apr 2012   Updated: 27 Apr 2012   Rating: 4.96/5    Votes: 21   Popularity: 6.45
Licence: CPOL    Views: 64,955     Bookmarked: 26   Downloaded: 521
Please Sign up or sign in to vote.
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.
6 Oct 2020   Updated: 6 Oct 2020   Rating: 5.00/5    Votes: 34   Popularity: 7.46
Licence: CPOL    Views: 51,673     Bookmarked: 12   Downloaded: 0
Please Sign up or sign in to vote.
First steps in development: break it, break it again!
1 Oct 2017   Updated: 11 Nov 2021   Rating: 4.79/5    Votes: 63   Popularity: 8.30
Licence: CPOL    Views: 95,024     Bookmarked: 20   Downloaded: 0
Please Sign up or sign in to vote.
When they first meet them, developers are often tempted to play with pre- and post- increment operators. Then they get confused, because they don't do what is expected. Or ... do they?
SQL
2 Jul 2016   Updated: 2 Jul 2016   Rating: 4.49/5    Votes: 19   Popularity: 5.52
Licence: CPOL    Views: 216,625     Bookmarked: 7   Downloaded: 0
Please Sign up or sign in to vote.
Why do I get an error "Column 'name' is invalid in the select list because t is not contained in either an aggregate function or the GROUP BY clause."? Well, it's pretty simple when you think about what GROUP BY does.
14 Feb 2022   Updated: 14 Feb 2022   Rating: 5.00/5    Votes: 5   Popularity: 3.49
Licence: CPOL    Views: 6,964     Bookmarked: 7   Downloaded: 0
Please Sign up or sign in to vote.
By the time you have read this, you will have no problem with compiling your programs ever again. Well, probably you won't. OK - maybe a little. Depends on the compiler.
Security
Encryption
20 Jun 2019   Updated: 20 Jun 2019   Rating: 4.60/5    Votes: 7   Popularity: 3.89
Licence: CPOL    Views: 17,812     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
I've seen quite a few questions asking how to decrypt SHA and MD5 to obtain the original input, mostly related to "encrypted passwords" and I thought I'd try to explain why the answer is "you can't".
TESmart
1 Mar 2023   Updated: 1 Mar 2023   Rating: 3.00/5    Votes: 2   Popularity: 0.90
Licence: CPOL    Views: 3,941     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
A new mouse and a new switch: this should be fun

Average blogs rating:

No blogs have been submitted.

Average tips rating: 4.81

19 May 2022   Updated: 19 May 2022   Rating: 4.68/5    Votes: 6   Popularity: 3.64
Licence: CPOL    Views: 5,010     Bookmarked: 3   Downloaded: 10
Please Sign up or sign in to vote.
Unless you have sufficient permissions (i.e. you are a protector) you can't see the moderation queue, so this is useless to you. Sorry!Spam waves: A flood of spammers filling the moderation queue with new users all advertising the same thing.
.NET
28 Jul 2013   Updated: 28 Jul 2013   Rating: 4.81/5    Votes: 11   Popularity: 4.81
Licence: CPOL    Views: 9,420     Bookmarked: 6   Downloaded: 213
Please Sign up or sign in to vote.
The MessageBox class works, but...why is it in the middle of the screen? Why does it expand to stupid sizes? Why can't the user copy and paste from it? So, I brewed my own.
28 Apr 2011   Updated: 29 Apr 2011   Rating: 4.38/5    Votes: 8   Popularity: 3.96
Licence: CPOL    Views: 30,224     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
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.
Database Development
14 Jan 2012   Updated: 14 Jan 2012   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 66,989     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
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.
SQL Server
23 Sep 2012   Updated: 23 Sep 2012   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 19,670     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
Inserting a number of rows in a database isn't difficult, but how do you do it in a single command without concatenating strings?
26 Sep 2012   Updated: 27 Sep 2012   Rating: 4.98/5    Votes: 17   Popularity: 6.00
Licence: CPOL    Views: 96,843     Bookmarked: 7   Downloaded: 0
Please Sign up or sign in to vote.
Why? Normally, it's because you stored it wrong...
18 Sep 2012   Updated: 18 Sep 2012   Rating: 4.94/5    Votes: 26   Popularity: 6.91
Licence: CPOL    Views: 131,793     Bookmarked: 39   Downloaded: 9,009
Please Sign up or sign in to vote.
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.
24 Feb 2014   Updated: 24 Feb 2014   Rating: 4.88/5    Votes: 5   Popularity: 3.41
Licence: CPOL    Views: 65,086     Bookmarked: 10   Downloaded: 0
Please Sign up or sign in to vote.
If you have an SQL column which contains a comma separated list of names, you may have wondered how to return it as individual rows in a SELECT statement. It's not too bad, really!
18 Jan 2015   Updated: 19 Jan 2015   Rating: 4.96/5    Votes: 8   Popularity: 4.48
Licence: CPOL    Views: 80,241     Bookmarked: 10   Downloaded: 218
Please Sign up or sign in to vote.
Sometimes, you want to extract the filename (with or without the extension) from the full path of a file. It's easy in C# and so forth - just use the Path.GetFileName method. But what if you want it in SQL?
26 Jul 2017   Updated: 26 Jul 2017   Rating: 4.38/5    Votes: 16   Popularity: 5.01
Licence: CPOL    Views: 23,278     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
Did you know that Windows provides a built in way to build SQL connection strings for you? Neither did I ... until I found UDL files.
28 Oct 2017   Updated: 28 Oct 2017   Rating: 4.38/5    Votes: 9   Popularity: 4.17
Licence: CPOL    Views: 35,466     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
How do you call a Stored Procedure inside a query and use the SELECT results? Tricky...or is it?
20 Sep 2018   Updated: 20 Sep 2018   Rating: 4.00/5    Votes: 4   Popularity: 2.41
Licence: CPOL    Views: 9,660     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
If you try to pass a DbNull.Value to an SQL Image column, you get an exception: "Operand type clash: nvarchar is incompatible with image" - not sure why it's throwing that, but it can be done.
DateTime
14 Jul 2011   Updated: 14 Jul 2011   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 44,622     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
Strangely, the .NET DateTime does not provide a Week Number. This extension rectifies this.
Desktop Programming
Windows Forms
8 May 2011   Updated: 8 May 2011   Rating: 4.79/5    Votes: 12   Popularity: 4.79
Licence: CPOL    Views: 40,992     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
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.
17 Apr 2023   Updated: 17 Apr 2023   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 11,238     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
How to add images to a Winforms Project so they are accessible as resources
WPF
27 Apr 2019   Updated: 27 Apr 2019   Rating: 5.00/5    Votes: 9   Popularity: 4.77
Licence: CPOL    Views: 27,065     Bookmarked: 13   Downloaded: 0
Please Sign up or sign in to vote.
This is an alternative for "List Only Files Created or Modified Yesterday in C#"
DevOps
Git
25 Apr 2015   Updated: 25 Apr 2015   Rating: 4.68/5    Votes: 13   Popularity: 5.21
Licence: CPOL    Views: 117,111     Bookmarked: 26   Downloaded: 0
Please Sign up or sign in to vote.
Getting started with GIT, Visual Studio, and BitBucket isn't difficult - but it can take a bit of working out. Here is a simple explanation of what to do to get a new project under source control.
General Programming
5 Jul 2010   Updated: 5 Jul 2010   Rating: 5.00/5    Votes: 22   Popularity: 6.61
Licence: CPOL    Views: 38,172     Bookmarked: 13   Downloaded: 0
Please Sign up or sign in to vote.
Marking code you need to return to later
Exceptions
10 Oct 2012   Updated: 10 Oct 2012   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 17,431     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
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
Printing
15 Dec 2022   Updated: 15 Dec 2022   Rating: 5.00/5    Votes: 5   Popularity: 3.49
Licence: CPOL    Views: 11,100     Bookmarked: 10   Downloaded: 0
Please Sign up or sign in to vote.
How to print labels in Word
Mobile Apps
Android
13 Mar 2015   Updated: 13 Mar 2015   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 12,531     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
If (like me) you have a Nexus7 that was converted into a door-stop by Lollipop 5.0 or 5.0.2, this is a guide in how to skip the wait for Google to realise you might want 5.1!
Operating Systems
Win10
20 Aug 2016   Updated: 20 Aug 2016   Rating: 5.00/5    Votes: 6   Popularity: 3.89
Licence: CPOL    Views: 14,960     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
Fast startup in Win10 seems to conflict with some apps, on some machines: I've seen it affect Chrome and Live Mail for example, as well as making shutdown a very long process on some laptops. But it's not obvious where the control for this is, hence this tip.
Windows
23 Aug 2020   Updated: 23 Aug 2020   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 7,258     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
Windows 10 and the ongoing "I can't find your mapped drives anymore" problem. A fix, hopefully!
7 Sep 2020   Updated: 7 Sep 2020   Rating: 4.76/5    Votes: 5   Popularity: 3.33
Licence: CPOL    Views: 14,114     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
How to automatically copy release executables to a specific folder on a successful build
Productivity Apps and Services
Microsoft Office
8 Feb 2014   Updated: 8 Feb 2014   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 18,552     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
Reading a sheet into a database isn't difficult - it's just I keep forgetting how... :sigh: So I abstracted this from my working code so I wouldn't lose it again.
Programming Languages
ASP
3 Jan 2011   Updated: 5 Jan 2011   Rating: 4.33/5    Votes: 3   Popularity: 2.07
Licence: CPOL    Views: 28,313     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
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...
C#
10 Feb 2013   Updated: 11 Feb 2013   Rating: 4.98/5    Votes: 20   Popularity: 6.48
Licence: CPOL    Views: 69,748     Bookmarked: 19   Downloaded: 0
Please Sign up or sign in to vote.
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...
20 Apr 2012   Updated: 20 Apr 2012   Rating: 5.00/5    Votes: 34   Popularity: 7.66
Licence: CPOL    Views: 130,653     Bookmarked: 44   Downloaded: 0
Please Sign up or sign in to vote.
There is a common theme in development: storing data files in the application folder. This is bad, and wrong, and should be stamped on!
29 Jun 2013   Updated: 30 Jun 2013   Rating: 4.80/5    Votes: 4   Popularity: 2.89
Licence: CPOL    Views: 12,441     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
One of the tasks we often have to do is rename a file before creating a new version. But when we want to keep multiple versions, how do we find out which ones already exist?
20 Jan 2020   Updated: 20 Jan 2020   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 10,535     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
It's pretty easy to let Windows Explorer drop files on a WinForms app, but I can never remember how. So since I needed a "file touch" app, I thought I'd document the process here.
23 Apr 2018   Updated: 23 Apr 2018   Rating: 5.00/5    Votes: 7   Popularity: 4.23
Licence: CPOL    Views: 10,251     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
How to colour the individual cells of a DataGridView according to their content. For example, negative values can be Red, positive values Green to show "Up"s and "Down"s more easily.
2 Sep 2015   Updated: 2 Sep 2015   Rating: 4.93/5    Votes: 7   Popularity: 4.17
Licence: CPOL    Views: 27,188     Bookmarked: 7   Downloaded: 1,253
Please Sign up or sign in to vote.
Sometimes, a chart can make data a lot easier to understand - but why does the Chart control make it so difficult to display multiple lines from a collection of objects?
31 Jul 2018   Updated: 31 Jul 2018   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 8,711     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
Winforms BindingSource does not support Parameterized Queries - so your app crashes when your user types "doesn't"
21 Oct 2015   Updated: 21 Oct 2015   Rating: 5.00/5    Votes: 16   Popularity: 5.88
Licence: CPOL    Views: 24,372     Bookmarked: 16   Downloaded: 668
Please Sign up or sign in to vote.
A simple "scratch card" like control for Winforms, where the user can reveal the image by "scratching off" a cover
16 May 2012   Updated: 16 May 2012   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 12,400     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
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?
9 Jan 2019   Updated: 9 Jan 2019   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 9,255     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
How to open a file specifically in the default browser, instead of the default app for the file type
19 Feb 2013   Updated: 3 Apr 2013   Rating: 5.00/5    Votes: 19   Popularity: 6.28
Licence: CPOL    Views: 56,950     Bookmarked: 21   Downloaded: 1,009
Please Sign up or sign in to vote.
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.
18 Feb 2013   Updated: 3 Apr 2013   Rating: 3.82/5    Votes: 23   Popularity: 5.20
Licence: CPOL    Views: 71,654     Bookmarked: 20   Downloaded: 1,655
Please Sign up or sign in to vote.
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.
18 Feb 2013   Updated: 3 Apr 2013   Rating: 4.94/5    Votes: 11   Popularity: 4.94
Licence: CPOL    Views: 44,898     Bookmarked: 15   Downloaded: 862
Please Sign up or sign in to vote.
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.
8 Aug 2013   Updated: 8 Aug 2013   Rating: 4.20/5    Votes: 3   Popularity: 2.00
Licence: CPOL    Views: 12,992     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
If (like me) you use the Assembly version of your EXE to handle versioning, and you (like me) use the Settings.Settings for configuration items, then you've probably noticed the config is lost when the version is changed.
3 Sep 2017   Updated: 3 Sep 2017   Rating: 4.20/5    Votes: 2   Popularity: 1.26
Licence: CPOL    Views: 22,637     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
How to pass parameters to a PrintDocument.PrintPage event
21 Nov 2017   Updated: 21 Nov 2017   Rating: 4.33/5    Votes: 3   Popularity: 2.07
Licence: CPOL    Views: 26,356     Bookmarked: 6   Downloaded: 182
Please Sign up or sign in to vote.
There is a problem with accessing Excel files via OleDb which contain more than 255 columns: they are truncated and need to be fetched using ranges. But what do you do with DataTables after that?
25 Jun 2012   Updated: 25 Jun 2012   Rating: 4.71/5    Votes: 7   Popularity: 3.98
Licence: CPOL    Views: 43,356     Bookmarked: 10   Downloaded: 238
Please Sign up or sign in to vote.
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.
23 Dec 2017   Updated: 23 Dec 2017   Rating: 5.00/5    Votes: 7   Popularity: 4.23
Licence: CPOL    Views: 10,650     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
Does your derived class open in the Visual Studio Designer while having no UI? Annoying, isn't it? This is simple to fix.
28 Mar 2014   Updated: 28 Mar 2014   Rating: 4.85/5    Votes: 10   Popularity: 4.85
Licence: CPOL    Views: 28,841     Bookmarked: 12   Downloaded: 0
Please Sign up or sign in to vote.
Want to use Linq, or Linq methods with the results from your Regex? Yes, so did I...annoying isn't it? So...a solution.
12 Apr 2012   Updated: 12 Apr 2012   Rating: 5.00/5    Votes: 6   Popularity: 3.89
Licence: CPOL    Views: 15,392     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
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!
13 Jun 2012   Updated: 13 Jun 2012   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 17,000     Bookmarked: 0   Downloaded: 98
Please Sign up or sign in to vote.
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.
29 Oct 2013   Updated: 29 Oct 2013   Rating: 4.83/5    Votes: 3   Popularity: 2.31
Licence: CPOL    Views: 17,043     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
Abstract base classes are a very good idea - but when that base class is a UserControl, Visual studio gets very unfriendly. It is possible, and it's not difficult: you just have to know how to do it.
13 Apr 2014   Updated: 13 Apr 2014   Rating: 4.93/5    Votes: 20   Popularity: 6.31
Licence: CPOL    Views: 90,726     Bookmarked: 26   Downloaded: 0
Please Sign up or sign in to vote.
Sometimes, I need to create files or folders directly, and use existing data to provide the file name - and then my app throws an exception because there are "illegal characters in the file name" - so this is a simple way to remove them.
1 Feb 2010   Updated: 5 Dec 2015   Rating: 4.82/5    Votes: 27   Popularity: 6.74
Licence: CPOL    Views: 64,693     Bookmarked: 18   Downloaded: 0
Please Sign up or sign in to vote.
Hiding inherited properties and tasks in derived classes
25 May 2014   Updated: 25 May 2014   Rating: 4.88/5    Votes: 5   Popularity: 3.41
Licence: CPOL    Views: 16,712     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
I needed to show file sizes in a "human friendly format" recently, so I thought I'd knock up a simple method to do it. So the file sizes such as 10123456789 bytes would display as 10.1Gb and so forth.
6 Jun 2015   Updated: 6 Jun 2015   Rating: 3.63/5    Votes: 4   Popularity: 2.18
Licence: CPOL    Views: 16,210     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
If you have two DataTables and you want to join the "matching" rows together in a new table, this provides a simple way to do it.
2 Jul 2012   Updated: 2 Jul 2012   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 13,647     Bookmarked: 3   Downloaded: 72
Please Sign up or sign in to vote.
Converting a value to an SI unit string.
14 Jun 2012   Updated: 14 Jun 2012   Rating: 5.00/5    Votes: 8   Popularity: 4.52
Licence: CPOL    Views: 25,443     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
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.
22 Nov 2015   Updated: 22 Nov 2015   Rating: 4.20/5    Votes: 2   Popularity: 1.26
Licence: CPOL    Views: 13,431     Bookmarked: 3   Downloaded: 185
Please Sign up or sign in to vote.
When you perform a mouse action on a TabControl tab, it isn't passed to the relevant TabPage. This shows how to do that.
15 Jul 2011   Updated: 18 Jul 2011   Rating: 4.98/5    Votes: 26   Popularity: 7.05
Licence: CPOL    Views: 95,860     Bookmarked: 24   Downloaded: 0
Please Sign up or sign in to vote.
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.
9 Jan 2012   Updated: 18 Jun 2012   Rating: 4.87/5    Votes: 30   Popularity: 7.19
Licence: CPOL    Views: 168,162     Bookmarked: 34   Downloaded: 273
Please Sign up or sign in to vote.
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?
30 Mar 2013   Updated: 30 Mar 2013   Rating: 5.00/5    Votes: 12   Popularity: 5.40
Licence: CPOL    Views: 28,115     Bookmarked: 17   Downloaded: 143
Please Sign up or sign in to vote.
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.
13 Feb 2017   Updated: 13 Feb 2017   Rating: 4.71/5    Votes: 8   Popularity: 4.26
Licence: CPOL    Views: 12,561     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
I embed a ToDo.txt and a RevisionHistory.txt file in every assembly - it helps me keep track of what has changed - and it normally gets read out and displayed in the "Help...About" dialog. But what if you want to read an embedded file from a different Assembly?
26 Oct 2013   Updated: 26 Oct 2013   Rating: 4.91/5    Votes: 9   Popularity: 4.68
Licence: CPOL    Views: 46,830     Bookmarked: 15   Downloaded: 642
Please Sign up or sign in to vote.
StringBuilder is a very useful and memory efficient way to concatenate strings, but there is no obvious similar class for byte arrays. This class adds that, and provides a flexible binary data storage medium at the same time.
21 Jul 2016   Updated: 21 Jul 2016   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 13,190     Bookmarked: 1   Downloaded: 33
Please Sign up or sign in to vote.
Scoring the FOSW of the day for people who find it difficult
2 Apr 2012   Updated: 2 Apr 2012   Rating: 4.85/5    Votes: 24   Popularity: 6.52
Licence: CPOL    Views: 149,180     Bookmarked: 31   Downloaded: 0
Please Sign up or sign in to vote.
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...
20 Jul 2010   Updated: 23 Jul 2010   Rating: 4.29/5    Votes: 7   Popularity: 3.62
Licence: CPOL    Views: 13,520     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
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
12 Aug 2010   Updated: 12 Aug 2010   Rating: 4.43/5    Votes: 11   Popularity: 4.61
Licence: CPOL    Views: 20,222     Bookmarked: 10   Downloaded: 0
Please Sign up or sign in to vote.
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.
26 Aug 2010   Updated: 26 Aug 2010   Rating: 4.67/5    Votes: 3   Popularity: 2.23
Licence: CPOL    Views: 20,091     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
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!
2 Mar 2011   Updated: 3 Mar 2011   Rating: 4.88/5    Votes: 54   Popularity: 8.37
Licence: CPOL    Views: 183,132     Bookmarked: 52   Downloaded: 0
Please Sign up or sign in to vote.
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!
25 Apr 2011   Updated: 29 Apr 2011   Rating: 4.93/5    Votes: 94   Popularity: 9.68
Licence: CPOL    Views: 161,625     Bookmarked: 115   Downloaded: 0
Please Sign up or sign in to vote.
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.
31 Jul 2011   Updated: 31 Jul 2011   Rating: 4.50/5    Votes: 8   Popularity: 4.06
Licence: CPOL    Views: 23,932     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
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.
16 Sep 2011   Updated: 18 Sep 2011   Rating: 4.85/5    Votes: 14   Popularity: 5.56
Licence: CPOL    Views: 59,798     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
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.
10 Oct 2011   Updated: 10 Oct 2011   Rating: 4.80/5    Votes: 5   Popularity: 3.36
Licence: CPOL    Views: 26,291     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
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...
4 Jan 2012   Updated: 7 Jan 2012   Rating: 4.83/5    Votes: 14   Popularity: 5.22
Licence: CPOL    Views: 130,219     Bookmarked: 11   Downloaded: 0
Please Sign up or sign in to vote.
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.
12 Jan 2012   Updated: 13 Jan 2012   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 45,664     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
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.
24 Jan 2012   Updated: 31 Jan 2012   Rating: 4.83/5    Votes: 16   Popularity: 5.53
Licence: CPOL    Views: 51,291     Bookmarked: 15   Downloaded: 0
Please Sign up or sign in to vote.
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.
19 Aug 2010   Updated: 12 May 2013   Rating: 4.91/5    Votes: 77   Popularity: 9.05
Licence: CPOL    Views: 133,051     Bookmarked: 14   Downloaded: 0
Please Sign up or sign in to vote.
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.
17 Jan 2024   Updated: 17 Jan 2024   Rating: 5.00/5    Votes: 10   Popularity: 5.00
Licence: CPOL    Views: 10,590     Bookmarked: 21   Downloaded: 0
Please Sign up or sign in to vote.
Why switch from the "traditional" BackgroundWorker to a Task? The old way works OK, but the new way generates "tidier" code which keeps stuff together (and needs less code)
31 Oct 2013   Updated: 31 Oct 2013   Rating: 4.92/5    Votes: 3   Popularity: 2.35
Licence: CPOL    Views: 7,440     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
Sometimes (far too often, I find) you will try to open a form in the Visual Studio designer, and it won't open it because "the type X declared in Project X is not the same as the type X declared in Project X". This is annoying, as well as being blatantly untrue. Stop laughing at the back there!
17 Jun 2014   Updated: 17 Jun 2014   Rating: 5.00/5    Votes: 20   Popularity: 6.51
Licence: CPOL    Views: 31,990     Bookmarked: 12   Downloaded: 11
Please Sign up or sign in to vote.
The Article editor does work - but sometimes it does do things the hard way, and tries to frustrate you on purpose, I'm sure...
C# 3.5
27 May 2014   Updated: 27 May 2014   Rating: 5.00/5    Votes: 5   Popularity: 3.49
Licence: CPOL    Views: 62,742     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
This is really easy - but it's hard to work out for the first time. For example, get a list of files, and group them by the date which is in the 2nd to 10th characters of the name, ignoring extensions. Easy!
C# 5.0
3 Jul 2014   Updated: 3 Jul 2014   Rating: 4.74/5    Votes: 10   Popularity: 4.74
Licence: CPOL    Views: 24,444     Bookmarked: 14   Downloaded: 603
Please Sign up or sign in to vote.
I've answered quite a few questions in the last couple of months about how to get the physical location of a client from a website. And people seem to get annoyed when I say: "Don't. It's no real use". But that's the truth: you can get it, but it won't be accurate. Let's have a look and see why.
C# 8.0
16 Jul 2023   Updated: 16 Jul 2023   Rating: 4.98/5    Votes: 10   Popularity: 4.98
Licence: CPOL    Views: 10,311     Bookmarked: 8   Downloaded: 0
Please Sign up or sign in to vote.
I am switching to C# 8 / .NET 7 so I'm recreating my project templates to create suitable versions. And it's not trivial as some things are very different.
SQL
18 Dec 2013   Updated: 18 Dec 2013   Rating: 4.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 8,700     Bookmarked: 7   Downloaded: 0
Please Sign up or sign in to vote.
Getting totals for a specific period: this week, this month, this year. And last week, last month, and last year.
27 Apr 2013   Updated: 7 May 2013   Rating: 4.92/5    Votes: 23   Popularity: 6.70
Licence: CPOL    Views: 348,320     Bookmarked: 24   Downloaded: 273
Please Sign up or sign in to vote.
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.
14 Jul 2013   Updated: 14 Jul 2013   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 7,180     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
If you have two (or more) tables which are interrelated, you sometimes need to update the rows of one table, selected from information in a different table. This isn't difficult, but is can take a little think about.
24 Mar 2020   Updated: 24 Mar 2020   Rating: 4.57/5    Votes: 6   Popularity: 3.56
Licence: CPOL    Views: 14,856     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
A basic user defined function to remove minute and second from a DATETIME
26 Dec 2019   Updated: 26 Dec 2019   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 3,633     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Select users with a birthday in the next "n" days is pretty easy, if you use the day of year. The only slight complication is the need to "wrap" round the year end.
14 Sep 2021   Updated: 14 Sep 2021   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 8,142     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
How do you get last weeks data only? It's a little more complex than you might have thought
Visual Basic
26 Jan 2010   Updated: 26 Jan 2010   Rating: 4.86/5    Votes: 12   Popularity: 5.24
Licence: CPOL    Views: 55,026     Bookmarked: 7   Downloaded: 0
Please Sign up or sign in to vote.
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()...
26 Jan 2010   Updated: 18 Feb 2012   Rating: 4.97/5    Votes: 27   Popularity: 7.11
Licence: CPOL    Views: 84,084     Bookmarked: 15   Downloaded: 0
Please Sign up or sign in to vote.
Disable the Close box on a form
Visual Studio
10 Feb 2011   Updated: 12 Feb 2011   Rating: 5.00/5    Votes: 49   Popularity: 8.41
Licence: CPOL    Views: 62,954     Bookmarked: 32   Downloaded: 0
Please Sign up or sign in to vote.
F1 in Visual Studio takes forever, and rarely comes up with anything useful. Replace it with a Google MSDN search!
17 Jul 2010   Updated: 9 Oct 2011   Rating: 4.96/5    Votes: 17   Popularity: 5.97
Licence: CPOL    Views: 26,652     Bookmarked: 15   Downloaded: 0
Please Sign up or sign in to vote.
Adding your items to Visual Studio default files
16 Nov 2011   Updated: 20 Nov 2011   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 20,131     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
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.
8 Jan 2012   Updated: 8 Jan 2012   Rating: 4.90/5    Votes: 10   Popularity: 4.68
Licence: CPOL    Views: 26,250     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
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.
Web Development
ASP.NET
5 Jan 2011   Updated: 7 Jan 2011   Rating: 5.00/5    Votes: 5   Popularity: 3.49
Licence: CPOL    Views: 27,952     Bookmarked: 13   Downloaded: 0
Please Sign up or sign in to vote.
Supporting Development and Release web.config in ASP.NET
7 Feb 2011   Updated: 8 Feb 2011   Rating: 5.00/5    Votes: 11   Popularity: 5.00
Licence: CPOL    Views: 18,943     Bookmarked: 9   Downloaded: 0
Please Sign up or sign in to vote.
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.
14 Aug 2011   Updated: 14 Aug 2011   Rating: 4.83/5    Votes: 5   Popularity: 3.38
Licence: CPOL    Views: 25,101     Bookmarked: 6   Downloaded: 0
Please Sign up or sign in to vote.
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.

Average reference rating:

No reference articles have been posted.

Average project rating:

No projects have been posted.
CEO
Wales Wales
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?