Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Wizard
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
this.CurrentPage = page11;
this.btnCancel.Enabled = false;
this.btnFinish.Enabled = false;
base.OnLoad(e);
}
private IPagePanel _currentPage;
public IPagePanel CurrentPage
{
get
{
return _currentPage;
}
set
{
_currentPage = value;
}
}
private void page11_Load(object sender, EventArgs e)
{
}
private void btnNext_Click(object sender, EventArgs e)
{
if (this.CurrentPage == page11)
{
this.CurrentPage = (IPagePanel)page21;
page21.Visible = false;
page21.Visible = true;
btnCancel.Enabled = true;
}
//else
//{
// this.CurrentPage = _thirdPageWizardPanel;
// _secondPageWizardPanel.Visible = false;
// _thirdPageWizardPanel.Visible = true;
// _cmdNext.Enabled = false;
// _cmdFinish.Enabled = true;
//}
}
}
}
上に示したコードは、私が作成したかったウィザードのものです。Page1とPage2は、私が使用するユーザーコントロールページです。
IPagePanel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wizard
{
public interface IPagePanel
{
}
}
ユーザーコントロールPage1とPage2は、2つの別々の名前空間にあります。
namespace Page1
{
partial class Page1
{
/// <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()
{
this.lblDescription = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblDescription
//
this.lblDescription.AutoSize = true;
this.lblDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDescription.Location = new System.Drawing.Point(228, 114);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(65, 20);
this.lblDescription.TabIndex = 0;
this.lblDescription.Text = "Page 1";
//
// Page1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lblDescription);
this.Name = "Page1";
this.Size = new System.Drawing.Size(547, 278);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblDescription;
}
}
エラーメッセージ:
エラー1タイプ「Page1.Page1」を「Wizard.IPagePanel」に暗黙的に変換できません。明示的な変換が存在します(キャストがありませんか?)2132ウィザード