Search code examples
c#zedgraph

ZedGraph on resize?


How can I access the event that is triggered when a graph pane is resized?

After each resize, I want to fix the text size on the title and labels so they don't get huge when the window is maximized.


Solution

  • You can subscribe for ZedGraphControl's resize event:

    zg1.Resize += new EventHandler(zg1_Resize);
    

    But it's easier to achieve what you want by disabling the automatic font scaling on the GraphPane:

    zg1.MasterPane[0].IsFontScaled = false;
    

    If you have more than one GraphPane on your MasterPane, use:

     foreach(GraphPane pane in zg1.MasterPane.PaneList)
        pane.IsFontScaled = false;
    

    See also:
    http://zedgraph.org/wiki/index.php?title=How_does_the_font_and_chart_element_scaling_logic_work%3F http://zedgraph.sourceforge.net/documentation/html/P_ZedGraph_PaneBase_IsFontsScaled.htm