- 01: 名前:TATUYA投稿日:2003/11/17(月) 14:14
- Visio2003より利用可能となった、Visio Drawing Control Active Xについて
Visio Drawing Controlを利用して、Windows ApplicationをC#で作成しました。
A画面→B画面 B画面→A画面 と遷移するものです。
A画面にはB画面への遷移するためのボタンを一つ
B画面にはA画面に遷移するためのボタンと、Visio Drawing Controlを配置
で、Visual Studio .NET2003より、コードはある程度自動生成してもらいました。
そして実行します。
一回目、A画面→B画面→B画面→A画面
ここまでは旨く行きます。
が、続けて、
A画面→B画面
と遷移した際に、エラーが発生します。
サンプルに使用したソースの内容を送ります。
Form1.cs----------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Form1 の概要の説明です。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows フォーム デザイナ サポートに必要です。
//
InitializeComponent();
//
// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
//
}
/// <summary>
/// 使用されているリソースに後処理を実行します。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows フォーム デザイナで生成されたコード
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 16);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary&
<省略されました> [全文を見る]
- 02: 名前:BOB投稿日:2003/11/18(火) 08:11
- こんにちは、エラーの内容はどんなでしたか?
VB.NETで同じように作成するとエラーなく動きます。
ちなみに
public Form2(Form form)
{
pre = form;
ではなくForm2でもFormと同様にクリック時に明示的に
Formのオブジェクトを生成しShowしています。
以上です。
- 03: 名前:TATUYA投稿日:2003/11/18(火) 12:38
- お返事ありがとうございます。
VB.NETで試してみました。
問題箇所が鮮明になりました。
画面遷移を行う際、遷移元の画面を消して歩くと、
Drawing Control のイニシャライズ時にエラーが発生するようです。
<Form1のボタン処理>
form2.show()
Me.Dispose()
↓
<Form2のボタン処理>
form1show()
form2Dispose()
↓
<Form1のボタン処理>
form2.show() ※ エラー発生
エラーはSystem.NullReferenceException(オブジェクトはニューしてるのに;;
イニシャライズ内のエラー部分は以下です。
CType(Me.AxDrawingControl1, System.ComponentModel.ISupportInitialize).EndInit()
っと、書いている途中で実現できました。
Me.Dispose(False)
とすると、うまくいきます。
…なんでだろ。
■トップに戻る リロード 単独スレ表示
|