When programming get's me down

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Working on a large legacy Winforms app. in VS2015

On a form I have a table with 4 columns, each column set to 25% width and each of the four columns containing it's own table. So I add controls to the 4 tables hoping for a neat alignment. The columns within the individual 4 tables are set to autosize with the controls within them docked to fill. To make a long story short, the rendering is unpredictable and apparently tied to a sequence of steps:

When I decided to use autosize for the controls within the columns of each of the 4 individual tables the following happens:

1) Change columns to autosize then run the project. Rendering is wrong, the length of the columns stay fixed.

2) Stop the debugging session and change the columns back to fixed width. Run the project with fixed length columns. Stop the project and change the columns back to autosize. Run the project again. Rendering is closer to what was expected (stretched to fit screen).

3) Check that I am not going mad: change the columns to fixed WITHOUT running the project. Change the columns to autosize again. Run the project and the rendering is wrong again with fixed length rendering of the columns.

Repeat these steps a couple of times for control and it indeed seems the rendering is dependent on me running the project first while the columns are fixed-length, i.e. it can't be fixed length and then changed to autosize WITHOUT running the project first with the fixed length columns.

I am using Janus controls thought, so it may be a flaw of theirs rather than Microsoft (?)
 

Spacerat

Expert Member
Joined
Jul 29, 2015
Messages
1,328
Dont think tables withing tables is such a good idea. Maybe rethink the presentation or just do 16 columns?
 

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Dont think tables withing tables is such a good idea. Maybe rethink the presentation or just do 16 columns?

I'm getting that impression yes, though I have had the need to do so quite a few times in the past. If only it was WPF/XAML project and not Winforms...
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
No idea what this is but if it takes css then send it to me and I'll have a look I like the front end side of stuff especially responsiveness
 

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Are you setting the columns to auto size/fixed in the ui or in code?

In the UI/designer

What bothers me is not the problem at hand, or even a possible bug, but that you have a scenario where the outcome is dependent on the sequence of steps you take. If I did not discover by chance the 'correct' sequence then I would still be thinking that I am at fault and be searching around / reading up on how to do it properly.
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
In the UI/designer

What bothers me is not the problem at hand, or even a possible bug, but that you have a scenario where the outcome is dependent on the sequence of steps you take. If I did not discover by chance the 'correct' sequence then I would still be thinking that I am at fault and be searching around / reading up on how to do it properly.

Oh yea that's programming I am now discovering.
 

Spacerat

Expert Member
Joined
Jul 29, 2015
Messages
1,328
Yes I have found quite often that the designer messes up. When this happens. I just code the UI setup in the form ctor just underneath the InitializeComponents()

Just remember to SuspendLayout() and ResumeLayout() as well...
 

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Yes I have found quite often that the designer messes up. When this happens. I just code the UI setup in the form ctor just underneath the InitializeComponents()

Just remember to SuspendLayout() and ResumeLayout() as well...

Thanks, I used to go the code route in Silverlight/XAML a lot, not because of layout issues but it is easier to see at a glance what attributes/properties etc. are set. I hardly ever do it in Winforms though.
 
Top