Thursday, August 31, 2006

Changing Text on SplitContainer, what an interesting idea....

Today I rummaged through thousands lines of C# GUI code to find out why some things happen and some things didnt. Suddenly I see (through content assist) that one of the project specific controls has a TextChanged event. This control has nothing to do with text so it directly grabbed my attention.

Then I find out that it really isnt the specific control that implements the event, it is a control further up in the hiearchy. I keep going up the inheritance tree, to find that System.Windows.Forms.Control has a property named Text (and a bunch of events for text manipulations). That is odd I think, why would a base Control class have a text property when the deriving classes are not necessary text orientated controls.
  • What happens if I change the Text property on a PictureBox? Would it show the text on top of the picture?
  • What happens if I do it on a SplitContainer?
  • Or on a NumericUpDown control?
This is one of the problems with the .NET framework. It carries to much bagage from C++ and VB into the C# (and .NET) world. The old MFC libraries probably had a SetText() method, so therefore it must exist one in .NET. I wonder why they would have such functionality, and the only idea I can come up with is: It is simple if all text specific properties are named the same, and thus every control should have one. "If we keep it in Control, then we dont have to write code for text handling in every control". But what about all those controls that dont have a text in them? They must override this property and do nothing, so now we have code that hides other code just to remove a functionality. This does not make sense to me.

The MSDN will of course answer the question if the Text property actually works or not. On those controls that do not support them, it will say "This property supports the .NET Framework infrastructure and is not intended to be used directly from your code.". Sheeesh, that makes we want to think twice before using the Text property on a Label or Button. Perhaps the Text property is not intended to be used directly in my code on a button? The best explaination is (of course all these overriden properties have different wording) "The Text has no affect on the appearance of the NumericUpDown control; therefore, it is hidden in the designer and from IntelliSense.".. I would like to see that code in the IntelliSense.

if (control is SplitContainer) || (control is NumbericUpDown)

Or is there any valid reason that every Control has a Text property?

Friday, August 25, 2006

Nant is definetly not Ant (build MSBuild is)

As a newly born .NET/C# developer, I have trouble finding those must-have-tools. At my current job, they are running VS2005 in a huge system with over 70 seperate components/solution files with each having around 2000-10000 LOC. This gives me a huge headache as it takes forever to build, and everything is built with batch files. (so 90-ish)

But as a java developer, I have come to love Ant. There is a .NET version of it called NANT that I downloaded and was going to test and hopefully replace the batch files. 10 mins after downloading I stumble into the first problem. NANT does not support (as of 25 aug 2006) Visual Studio 2005. NANT can not handle the new solution files as they have change completly (not surprisingly). Apparently it is quite a job to add VS2005 support, so it seems that it is not going to happen. So NANT is definetly not ant, as it will probably cease to be used.

The new king of building MS code is MSBuild, which seems to be a total rip-off from Ant.

Wednesday, August 16, 2006

Its 2006 and MS has still learned nothing about installations!?

Due to a contractor job, I need to get some Visual C#/.NET/MSSQL experience. So I was going to install Visual C# Express (or as it is called Visual Studio 8, or other). I got the 3 mb installation file and started the installation (I hoped). The installation program did what they always do, Greetings&Saluations, Accept eula, Install MSDN and MSSQL?. Sure I could go for those as well. The program told me that I needed 1.7++ GBs of hard drive for this installation. Fine, I have plenty of space on my D-drive (data&Programs), which I told the program.

But wait a minute! That isnt how Ms wants it!

If I choose to install everything onto the d-drive, it would install 60 MBs on the D-drive and a whooping 1.7 GBs on the C-drive. But I thought I told VS to install on the d-drive and not onto the c-drive. Of course, I understand that VS requires some files to be installed on the c-drive. But 1.7 GBs, that is ridiculos.

Ok, regroup. Lets just choose the VSC# package, and I still want to install on the d-drive. Now it still wants to install 60 MBs on the d-drive and only 314 MBs on the c-drive.

When I left the MS development environment for six years ago, they still had this idea that I as a user shouldnt be allowed to make decisions like this. Still, they order me around and forces me to install everything on the c-drive. (The c-drive is already packed as every other program/driver wants to install onto the c-drive). I guess I can solve this the MS-user way, do a re-install every two years.

At least with Java, I'm old enough to choose where to put things.