Martin Spedding's Blog

Adventures in a disconnected world

March 2003 - Posts

Trouble with winforms - am I missing something ?

I decided that I would spruce up my winforms app and use the Magic user interface  library(http://www.dotnetmagic.com/). I decided the best way to do it was to create a temp form and then cut all the controls off the form I was going to change add the new controls and then paste back the controls that I had pasted in the temp form. Everything went well and all the event procedures were still in the form but of course the controls were no longer with their associated with event procedures. Which meant I had to rewire the whole form. But even more annoying than that, if I go to the events pane of the properties sheet for the control and clicked on the appropriate event to create the delegate it did not create a delegate for cboDay_TextChanged  but for  cboDay_TextChanged_1

I was wondering if I am missing something  or how other people deal with this problem ? It really is a pain. I know I could write a Visual Studio macro to deal with the problem but it would help if Visual Studio was a little bit more intelligent in the way in which it wired up events and controls.

Any ideas ?

Amazon shuts after price error

This amused me. It shame that saw it too late, I wouldn't have minded a pocket PC for £7.

######################################

The Amazon UK website was temporarily closed after a pricing error on its website saw pocket personal computers being sold for just £7.

The Hewlett Packard pocket computers were simultaneously retailing for $299 (£192) on the US site.

#######################################

http://news.bbc.co.uk/1/hi/business/2864461.stm

 

Scott McNealy saying that ".Net is a joke"

I have just noticed the story about Scott McNealy saying that ".Net is a joke" (via Drew March's log http://dotnetweblogs.com/dmarsh/posts/4035.aspx)

As he said it is an example of FUD but also it begs a number of questions:

(a) Is an indication that .Net is starting to have some sucess in the market and Sun is worried and needs to disparage it ?

(b) Does McNealy have any evidence to support his supposition ?

(c) Is McNealy really doing Sun any favours by making such ridiculous comments ?

I would have thought that Sun has more than enough problems of it's own with the increasing in roads that Linux will make in to it's business. 

I have programmed both in the Java world and with the .Net framework and certainly in terms of productivity I feel considering more productive in the .Net world.

Databinding - interesting behavior

I have been writing a rich client and I came across some interesting behaviour. If you are binding a control to a data source be careful about the order in which you bind the control.

Initially I used the following code :

cboDay.DataSource =myTimesheet.Tables["date"];
cboDay.DisplayMember="day";

However, there is a problem with this code if you happen to validate data which is typed into cboDay as the textchanged event will be fired as soon as you set the data source but the control will not contain the expected value until you set the datasource. In order to avoid this problem always set the display member and, if required, the value member prior to setting the data source.

In other words always use this sequence of commands :

cboDay.DisplayMember="day";
cboDay.DataSource =myTimesheet.Tables["date"];

Refactoring or cleaning up the code you wrote quickly

Recently I had to write an application very quickly, which mean that I did not have the time to design the application as throughly as I would have liked. In fact I had to make some very pragmatic decisions. I am sure that most developers find themselves in this situation more often than they would like. In the end it does not matter how good your code is, the important thing is to ship something. Luckly, the application is working and has shipped and no significant bugs have been found . However, I want to extend the application so now that I have some breathing space I have the opportunity to clean up the code.

I saw a reference to a C# Refactoring tool from Xtreme Simplicity a while a go,though sadly I don't have the original blog reference any more. I have to say that C# Refactory (http://www.xtreme-simplicity.net/ ) really has made the whole exercise so much easier. Sadly it is not open source like nant ( http://nant.sourceforge.net) and nunit (http://nunit.sourceforge.net) but it is not too expensive and I think it has increased my productivity as well as improving the quality of my code. After using JRefactory when developing Java applications it was great to be able to use another similar but more powerful tool for my C# application.

 

More Posts