Hello,

I am a java developer (with a few years experience). I have just been assigned my first C# project. So far I have only written UI in java (Swing), coding by hand. I have found this to be easy and manageable.

When I opened Visual Studio (not for the first time, I have worked with it before), working with the Designer View looked nice and easy. A lot of work is done behind the scenes for you, so you almost don't have to worry about coding the UI. Neat.

However, when specs change (and they always do), or when anything is slightly more complicated (e.g., a DataGridView with a very large data set), you need to actually manually alter the generated code. Just removing a button from a form gave me a bit of a headache.

In order to learn a bit about this, I downloaded the most famous open source C# project I could think of: Paint.NET. I had a look, and besides the fact that some C++ code is used (probably because of native compilation etc), I saw that I can't open most of the forms in the Designer View. This is the error I got:
The designer cannot process the code at line 870: this.AutoScaleMode = AutoScaleMode.Dpi; The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again.
What I assume is, that the programmers initially worked using the Design View, and then altered the code, thus disabling any future use of the Design View. Is this a normal coding convention?

Does anybody have any good tips on using Visual Studio to create UI that will have manageable code?

You can code your own UI elements, without playing with InitializeComponent method, this way called creating controls at run time.
But give me why you don't need to use VS Designer ??!!!

It's not that I don't need/want to use the VS Design View.

The problem is, that if I use it, there's so much clutter that it's very hard to manage the code.
If you have any good tips on managing that code, I'd be glad to hear them.

They manage it perfectly! they put it in separated file, [FormName].Designer.cs to not mix it with your own code.

OK, I think I see what you mean there.
I guess I didn't really understand what I was seeing in Solution Explorer.

Feels kind of silly that I missed that. I'm going to try working like that for a few days, and then post about the results if I run into any difficulty.

OK, best of luck, feel free to ask whenever you need!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.