Отображение элемента управления .NET Chart в MFC - PullRequest
0 голосов
/ 31 августа 2018

Я хочу показать элемент управления .NET Chart в диалоге MFC. Я использовал размещенный элемент управления через экземпляр CWinFormsControl. На стороне .NET я создал UserControl с элементами управления TextBox, Button и Chart.

К сожалению, я не могу установить свойства элемента управления Chart. Хотя сам элемент управления Chart распознается, ни одно из его свойств или методов не распознается / не доступно.

в формах / .NET:

namespace HostableUserControl
{
partial class UserControl1
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Component Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
        System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
        this.button1 = new System.Windows.Forms.Button();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
        ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(39, 25);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 0;
        this.button1.Text = "button1";
        this.button1.UseVisualStyleBackColor = true;
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(140, 163);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(98, 20);
        this.textBox1.TabIndex = 1;
        this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
        // 
        // chart1
        // 
        this.chart1.BorderSkin.SkinStyle = System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle.FrameThin1;
        chartArea1.Name = "ChartArea1";
        this.chart1.ChartAreas.Add(chartArea1);
        this.chart1.Location = new System.Drawing.Point(140, 23);
        this.chart1.Name = "chart1";
        series1.ChartArea = "ChartArea1";
        series1.Name = "Series1";
        this.chart1.Series.Add(series1);
        this.chart1.Size = new System.Drawing.Size(251, 134);
        this.chart1.TabIndex = 2;
        this.chart1.Text = "chart1";
        // 
        // UserControl1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
        this.Controls.Add(this.chart1);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.button1);
        this.Name = "UserControl1";
        this.Size = new System.Drawing.Size(394, 200);
        ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    public System.Windows.Forms.Button button1;
    public System.Windows.Forms.TextBox textBox1;
    public System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}

}

// в MFC (фрагмент):

CWinFormsControl<HostableUserControl::UserControl1> m_ctrl1;

{
    m_ctrl1.GetControl()->textBox1->Text = "hello world";  // this works
    m_ctrl1.GetControl()->chart1->Text = "hello world";    // this generates compiler error
}

Ошибка компилятора (VS2017):

ошибка C2039: «Текст»: не является членом системы :: Windows :: Forms :: DataVisualization :: Charting :: Chart '

Эта ошибка генерируется для всех открытых членов диаграммы.

Есть предложения?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...