how to draw four (or more) workareas horizontally?

后端 未结 1 1789
栀梦
栀梦 2020-12-06 23:57

Here is a peace of code which draws 1/2/3/4 (depends on remarks) charts:

private void button1_Click(object sender, EventArgs e)
    {
        List         


        
相关标签:
1条回答
  • 2020-12-07 00:53

    I think all the alignment properties actually are more about data aligning than about the areas themselves..

    Looks like the default Position = Auto will win with its own ideas about how to use the space best, until you switch it off; so I believe that you have to set the Positions of the ChartAreas in code. Here is an example to play with:

    float dist = 1f;
    float h = 23f;
    float w = 80f;
    
    CA1.Position = new ElementPosition(dist, dist * 2 + h * 0, w, h);
    CA2.Position = new ElementPosition(dist, dist * 3 + h * 1, w, h);
    CA3.Position = new ElementPosition(dist, dist * 4 + h * 2, w, h);
    CA4.Position = new ElementPosition(dist, dist * 5 + h * 3, w, h);
    

    The four numbers of an ElementPosition are floats that hold percentages (!) of the total chart area. I have allowed a little distance and set the ChartAreas to 23% height and 80% width.

    The good news is that these numbers will hold during resize..

    Here is a screenshot (without data):

    enter image description here

    Isn't is strange that these things are so very hard to find out? (This is my 3rd try at it..)

    0 讨论(0)
提交回复
热议问题