Richard Howells' Blog
Author: RichardHowells Created: 11 March 2008
Notes about the interesting (my definition) bits I discover in my programming. Plus, of course, the occasional tar pit.

DataGridView – how to show a subset in a DropDownColumn

The standard approach is to add event handlers for CellBeginEdit and CellEndEdit. In CellBeginEdit a new datasources is bound to the dropdown and in CellEndEdit the binding is reversed. Here is a sample from the DataGridVew FAQ.

private void dataGridView1_CellBeginEdit(object sender,         DataGridViewCellCancelEventArgs e)


if (e.ColumnIndex == territoryComboBoxColumn.Index)


// Set the combobox cell datasource to the filtered BindingSource

DataGridViewComboBoxCell dgcb = (DataGridViewComboBoxCell)dataGridView1                        [e.ColumnIndex, e.RowIndex];

dgcb.DataSource = filteredTerritoriesBS;


// Filter the BindingSource based upon the region selected

this.filteredTerritoriesBS.Filter = "RegionID = " +

this.dataGridView1[e.ColumnIndex - 1, e.RowIndex].Value.ToString();




Read More »

I've been working with a group who inherited some bad code when the software house supplying them went bust.  When the application added or updated data in SQL Server sometimes date values were accepted in US format and sometimes in UK format.  On the Test server it was one way and on the Live it was the other.

It's never good when live and test have different configurations but applications often need to work properly regardless of details like date format configurations.  The solution is to use parameters properly.  I wrote about it here.

I just wrote about using a generic extension method as an alternative casting syntax.  I've been using it in some code I've been working on.  I like it.

Find it in the Forum (click here)

A year ago I decided to try the delights of developing as a non-admin.  It’s been great, I didn’t regret it.

My machine has been showing the symptoms of software rot.  Yesterday evening I repaved my machine.  I organize my disk as a partition for the O/S plus software and a separate partition for data.  I did a total ground-zero reinstall of the O/S (Win XP Pro), on a freshly formatted partition.  One effect of that is that my new account has a new SID.  All the old files on my data partition allow me to read them – I’m a User, but they don’t let me delete/write/update because my new SID is different to the one they were created with.

I think I am going to have to live with manually changing file permission settings for many months to come – I’d be *very* interested to hear of any cute shortcuts to that process.  More important – I’m expecting to have to re-pave again, annually seems about normal for me.  What I'd really like is some ideas on what I can do to stop this problem next time?

Read More »

Got a text about a parcel?  Ignore it!

Read More »

I'm working in Edinburgh this week and it's the Edinburgh Festival time. Definitely .

Laura is up here too, ready for next term.  We were planning to go to see Paul Merton's improvisation show, but we only had one ticket.  I'd got the last one when tried to book for both of us.  We hoped we might be able to get a press return.

We couldn’t get a press ticket at the box office, she tried calling in a favour from someone who was working in the venue, but no joy.  So I was just keeping her company in the queue.  A venue worker went past collecting ticket stubs – “I’m just standing here – couldn’t get a ticket.”  Five minutes later she was back – "There’s a guy farther back in the queue with a spare ticket."  He sold it me for a tenner but I'd have given him £15. Whoo-hoo.  I don’t think Laura stopped laughing for a whole hour – it was *that* good.  I'd seen them before, but hey - it's improvisation. ...
Read More »

I've been away this week and using the local bus.  Mostly it's worked pretty well.

Read More »

Having a great time at IBM this week.

Read More »

I get calls to my mobile from these numbers.  The phone only ever rings once.  Even that ring is truncated as if the call is disconnected as soon as it possibly can be.

As it's clearly not a real person there I never call back.  I figure if a real person really wanted to talk to me then they would let the phone ring out.  Heck they might even leave a message.

So - more interesting - does anyone know who these people are?  Leave a comment if you have any ideas?  Double leave a comment if you know how to stop them!

I sold an item on eBay and it didn't arrive.  Fair enough it did get caught up in the industrial action back then.  But still they lost it. 

Read More »

Copyright 2002-15 by Dynamisys Ltd