Click here to Skip to main content
11,410,750 members (64,930 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows .NET
Hello all,

I need to arrange a number of elements (in this example: labels) and add and remove them during runtime. The big issue I have is that these elements need to have a "fixed" position, e.g. lblA needs to be always at 0, 0. Maybe this illustration is more helpful:

A D
B E
C F

BUT, and that's really bothering me, the tableLayoutPanel should autosize and not be wider than needed, so if only A, C and F are displayed it should look like this:

A
C
F

Now if I add X, it should look like

A X
C
F

BUT, if I remove A and add Y, it should look like:

C Y
F
X

Get the point? I could use either use a flowLayoutPanel but would not have any control of where the labels will be placed (only flowDirection) or use a tableLayoutPanel and will have a problem when for example A, C and Z are displayed:

A
C
____Z

(__ is an empty cell)

Z should be displayed always last but still not in a second row. I tried TableLayoutPanelGrowStyle.AddColumns but still, this is not what I'm looking for.

Is there any built-in feature of either the flowLayout- or tableLayoutPanel that I've overseen?

Best Regards
Dennis
Posted 31-Dec-12 0:35am
Comments
Sergey Alexandrovich Kryukov at 31-Dec-12 18:28pm
   
Does you panel have fixed or variable number of children? Do some of the children need to be fixed size, or some or all can have sizes defined by the current layout, form size?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hay Dennis,

you can use DevExpress Layout Control instead of this

Kindly let me know if you have any query
  Permalink  
Comments
URVISHSUTHAR at 2-Jan-13 3:30am
   
I'm using DevExpress and don't have others now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,918
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100