.NET Framework Developer Center > .NET Development Forums > Chart Controls for .NET Framework > Something Is Overriding TitleFont Settings for X axisand Y (Value) axis
Ask a questionAsk a question
 

AnswerSomething Is Overriding TitleFont Settings for X axisand Y (Value) axis

  • Thursday, October 29, 2009 10:36 PMTybeeChris Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi.  I am trying to set the font and font point size of my X axis and Y axis titles in design mode with the Axis Collection Editor window.  I can set the font to Arial 16pt Bold and it will stick until I click the Ok button on the Axis Collection Editor.  When I click the OK button on the Axis Collection Editor window the font gets reset to Microsoft Sans Serif 8pt Regular and I am returned to the ChartArea Collection Editor window.  I am new to the Chart control and can't seem to figure out why my X and Y axis Title Font settings won't "stick".  Something seems to be overriding them.

    Any help would be greatly appreciated as this is something not worth getting stuck on.

    Thanks,

    Chris

Answers

  • Tuesday, November 03, 2009 9:20 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You will see your change of Title fonts after applying title style through code.

    I had tried it, but in design mode, your style will go in air after applying if ChartArea's Area3DStyle's Enabled property is set to true.

    So, to generalise in 2D or 3D Chart Title application, try styling the fonts through code.

    Same thing you will notice in other FontStyles i.e for AxisFonts, SeriesFonts, TitleFonts etc. 
    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.
    • Marked As Answer byTybeeChris Tuesday, November 03, 2009 11:27 PM
    •  

All Replies

  • Friday, October 30, 2009 7:29 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    If you have set the Title fonts your wat, and you enable Area3DStyle to 3D mode, then it will be goe if you designed chart in design mode.

    Instead if you add Title font style dynamically as :

    SomeChart.Titles[PutTitleIndexHere].Font = new Font(SystemFontName, FontSize, FontStyle);

    This will work.


    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.
  • Monday, November 02, 2009 4:47 PMTybeeChris Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi.  I still can't figure this out so I thought I would give a better example.  Below are the steps to reproduce my problem.

    1.  Open the WinFormsChartSamples solution in Visual Studio 2008 (which is awesome by the way)

    2.  In Solution Explorer open the ChartFeatures folder, then open the Axis folder and finally open the AxisTitle folder.

    3.  Doubleclick on the AxisTitle.cs user control to display the chart and other controls.

    4.  Click on the Bar Chart control in design mode to make Chart1 active in the Properties window.

    5.  Open the ChartArea Collection Editor by clicking on the "..." button in the ChartAreas property.

    6.  Open the Axis Collection Editor by clicking on the "..." button in the Axes property.

    7.  Click on Member 0 in the upper left to highlight the X axis (might already be highlighted).

    8.  Type "My X Axis Title" in the Title propery of the X axis properties.

    9.  Click on the TitleFont property and the "..." button to the right of it.

    10.  In the Font dialog box change the size from 8 to 12 and click the OK button.

    11.  My X Axis Title should now appear for the chart in the 12 point size font.

    12.  Watch the font on the chart and Click the OK button in the Axis Collection Editor
          Notice that the font size (and font name if changed) will get reset back to  
          Microsoft Sans Serif 8 point which I don't want to happen.

    What is overriding the font I try to set for the TitleFont property in desing mode??

    Thanks for any replies,

    Chris
  • Tuesday, November 03, 2009 9:20 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You will see your change of Title fonts after applying title style through code.

    I had tried it, but in design mode, your style will go in air after applying if ChartArea's Area3DStyle's Enabled property is set to true.

    So, to generalise in 2D or 3D Chart Title application, try styling the fonts through code.

    Same thing you will notice in other FontStyles i.e for AxisFonts, SeriesFonts, TitleFonts etc. 
    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.
    • Marked As Answer byTybeeChris Tuesday, November 03, 2009 11:27 PM
    •  
  • Tuesday, November 03, 2009 11:31 PMTybeeChris Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for the answer Dhruv.  I am successfully styling the fonts through code.  I feel like this could be considered a "bug" though.  I don't understand why my changes can't be saved in design mode.  I thought that the purpose of design mode was to provide a WYSIWYG way of designing your charts.  Having to use code for some things and not others seems confusing to me.

    Thanks for the help though.

    Chris