locked
.NET default ChartArea indexer for Chart component in C++/CLI and .NET 4.0 and later RRS feed

  • Question

  • Hello,

    in .NET 3.5 and VS2008sp1  I could use this:

    this->chart1->ChartAreas[0]->InnerPlotPosition->Auto = true;

    but now, in VS2013 the IntelliSense gives me ERROR that there is only

    ::default[System::String^]::get instead of Int32 indexer i.e. I must use this sequence

    System::Collections::Generic::IEnumerator<System::Windows::Forms::DataVisualization::Charting::ChartArea^>^ ie = this->chart1->ChartAreas->GetEnumerator();
    ie->MoveNext();
    safe_cast<ChartArea^>(ie->Current)->InnerPlotPosition->Auto = true;

    but compiler IS CAPABLE to compile without any error.

    Where is problem ? IntelliSense has problem in VS2013 ?  --- as usually ?

    of course this code is nice for IntelliSense as well:

    System::Collections::Generic::IEnumerator<System::Windows::Forms::DataVisualization::Charting::ChartArea^>^ ie = this->chart1->ChartAreas->GetEnumerator();
    ie->MoveNext();
    this->chart1->ChartAreas[ ie->Current->Name ]->InnerPlotPosition->Auto = true;

    Here is Int32 indexer:  https://msdn.microsoft.com/cs-cz/library/dd468031%28v=vs.110%29.aspx

    and here is screenshot:

    https://drive.google.com/file/d/0B8m2GdF1vex9OGRfaFZvTUpQU1U/view?usp=sharing

    Can someone give me some explanation ?

    Thanks.


    • Edited by Jerry.Mouse Friday, November 6, 2015 10:37 AM update
    Friday, November 6, 2015 10:02 AM

Answers

  • as you can see in here

    https://drive.google.com/file/d/0B8m2GdF1vex9ajFYUVJiblAtdFU/view?usp=sharing

    your recipe does not work

    Try the suggested workaround too.

    • Marked as answer by Jerry.Mouse Tuesday, November 10, 2015 3:34 PM
    Saturday, November 7, 2015 8:09 PM

All replies

  • If you are interested in a simpler workaround, try this:

    Collection<ChartArea^> ^ areas = chart1->ChartAreas;
    areas[0]->InnerPlotPosition->Auto = true;

    By the way, these classes are not available in .NET 3.5 (according to documentation).


    • Edited by Viorel_MVP Saturday, November 7, 2015 7:56 AM
    Saturday, November 7, 2015 7:50 AM
  • as you can see in here

    https://drive.google.com/file/d/0B8m2GdF1vex9ajFYUVJiblAtdFU/view?usp=sharing

    your recipe does not work

    and I aked to someone why Intellisence gives me error but compiler is able to copile without any error.

    I think that there is bug somewhere, damn !

    Saturday, November 7, 2015 7:56 PM
  • as you can see in here

    https://drive.google.com/file/d/0B8m2GdF1vex9ajFYUVJiblAtdFU/view?usp=sharing

    your recipe does not work

    Try the suggested workaround too.

    • Marked as answer by Jerry.Mouse Tuesday, November 10, 2015 3:34 PM
    Saturday, November 7, 2015 8:09 PM
  • yes, workaround is nice
    Tuesday, November 10, 2015 3:34 PM