2012-06-22 4 views
1

나는 CellBlock.Designer.cs이 골격 코드를 각 3 × 3 사각형은 사용자가 제어 할 수있는 간단한 스도쿠 응용 프로그램을 작성하지 않고 자동으로 생성 된 코드에 불과 CellBlock.cs에서 :솔루션에서 사용자 지정 사용자 정의 컨트롤을 찾을 수 없습니까?

namespace Sudoku 
{ 
    partial class CellBlock 
    { 

     private System.ComponentModel.IContainer components = null; 

     protected override void Dispose(bool disposing) 
     { 
      if (disposing && (components != null)) 
      { 
       components.Dispose(); 
      } 
      base.Dispose(disposing); 
     } 


     private void InitializeComponent() 
     { 
      this.CellOne = new System.Windows.Forms.MaskedTextBox(); 
      this.CellFour = new System.Windows.Forms.MaskedTextBox(); 
      this.CellFive = new System.Windows.Forms.MaskedTextBox(); 
      this.CellSix = new System.Windows.Forms.MaskedTextBox(); 
      this.CellTwo = new System.Windows.Forms.MaskedTextBox(); 
      this.CellThree = new System.Windows.Forms.MaskedTextBox(); 
      this.CellSeven = new System.Windows.Forms.MaskedTextBox(); 
      this.CellEight = new System.Windows.Forms.MaskedTextBox(); 
      this.CellNine = new System.Windows.Forms.MaskedTextBox(); 
      this.SuspendLayout(); 
      // 
      // CellOne 
      // 
      this.CellOne.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
      this.CellOne.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 
      this.CellOne.Location = new System.Drawing.Point(8, 8); 
      this.CellOne.Mask = "0"; 
      this.CellOne.Name = "CellOne"; 
      this.CellOne.PromptChar = ' '; 
      this.CellOne.Size = new System.Drawing.Size(26, 26); 
      this.CellOne.TabIndex = 0; 
      this.CellOne.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; 

      //CellTwo through CellNine omitted for brevity 

     // 
     // CellBlock 
     // 
     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.CellNine); 
     this.Controls.Add(this.CellEight); 
     this.Controls.Add(this.CellSeven); 
     this.Controls.Add(this.CellThree); 
     this.Controls.Add(this.CellTwo); 
     this.Controls.Add(this.CellSix); 
     this.Controls.Add(this.CellFive); 
     this.Controls.Add(this.CellFour); 
     this.Controls.Add(this.CellOne); 
     this.Name = "CellBlock"; 
     this.Size = new System.Drawing.Size(107, 107); 
     this.ResumeLayout(false); 
     this.PerformLayout(); 

    } 

    private System.Windows.Forms.MaskedTextBox CellOne; 
    private System.Windows.Forms.MaskedTextBox CellFour; 
    private System.Windows.Forms.MaskedTextBox CellFive; 
    private System.Windows.Forms.MaskedTextBox CellSix; 
    private System.Windows.Forms.MaskedTextBox CellTwo; 
    private System.Windows.Forms.MaskedTextBox CellThree; 
    private System.Windows.Forms.MaskedTextBox CellSeven; 
    private System.Windows.Forms.MaskedTextBox CellEight; 
    private System.Windows.Forms.MaskedTextBox CellNine; 
} 

}이 파일에

주 파일 인 Sudoku.cs과 동일한 솔루션입니다. 간단히 프로젝트 메뉴를 통해 솔루션에 사용자 정의 컨트롤을 추가했습니다. Sudoku.Designer.cs의 코드입니다. Visual Studio에서 자동으로 생성됩니다.

namespace Sudoku 
{ 
    partial class Sudoku 
    { 

     private System.ComponentModel.IContainer components = null; 

     protected override void Dispose(bool disposing) 
     { 
      if (disposing && (components != null)) 
      { 
       components.Dispose(); 
      } 
      base.Dispose(disposing); 
     } 

     private void InitializeComponent() 
     { 
      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Sudoku)); 
      this.cellBlock1 = new Sudoku.CellBlock(); 
      this.cellBlock2 = new Sudoku.CellBlock(); 
      this.cellBlock3 = new Sudoku.CellBlock(); 
      this.cellBlock4 = new Sudoku.CellBlock(); 
      this.cellBlock5 = new Sudoku.CellBlock(); 
      this.cellBlock6 = new Sudoku.CellBlock(); 
      this.cellBlock7 = new Sudoku.CellBlock(); 
      this.cellBlock8 = new Sudoku.CellBlock(); 
      this.cellBlock9 = new Sudoku.CellBlock(); //errors occur at these lines 

} 


     private CellBlock cellBlock1; 
     private CellBlock cellBlock2; 
     private CellBlock cellBlock3; 
     private CellBlock cellBlock4; 
     private CellBlock cellBlock5; 
     private CellBlock cellBlock6; 
     private CellBlock cellBlock7; 
     private CellBlock cellBlock8; 
     private CellBlock cellBlock9; 

    } 
} 

나는 그게 내가 간결하게하기 위해 자동으로 생성 된 코드의 일부를 생략하고있어, 비록 모든 올바른 생각합니다. 내가 솔루션을 빌드 할 때, 나는 9 오류를 다음과 같이 얻을 : 유형 이름 '독방'는 유형 읽을 줄 참조 'Sudoku.Sudoku'

에 존재하지 않는 : 나는 어쩌면 내가 생각 this.cellBlock1 = new Sudoku.CellBlock();CellBlock, even though it's within the same solution, but when I click 참조 추가 '를 추가해야 할 경우 프로젝트 아래에 아무것도 표시되지 않습니다.

+0

어떤 줄 번호로 인해 오류가 발생합니까? – user12345613

+0

@ this.cellBlock1 = new Sudoku.CellBlock();을 읽는 줄 (내 편집 참조). –

+0

'this.cellBlock1 = new CellBlock(); ' – Damith

답변

2

Sudoku 이외의 새 이름으로 이름 공간의 이름을 바꾼 다음 솔루션을 정리하고 다시 작성하십시오.

현재 CellBlock 컨트롤을 제거하고 다시 추가하십시오.

+0

용액을 깨끗하게 청소하십시오. 도와 주셔서 감사합니다. –

1

나는 수업 Sudoku이 네임 스페이스 Sudoku과 동일하므로 컴파일러는 클래스 Sudoku 내부 CellBlock라는 내부 클래스가 있어야한다 생각하기 때문에 그것을 것 같아요. 나는 C# 런타임과 컴파일러를 편리하게 사용하여 시도하고 재현 할 수 없다.

네임 스페이스 또는 클래스 이름을 다시 고려하여 자체 식별자를 갖도록하십시오.

+0

클래스 이름을'SudokuWindow'에 다시 입력하고'this.cellBlock1 = new Sudoku '라인을 다시 고려했습니다. CellBlock();'this.cellBlock1 = new SudokuWindow.CellBlock();'은 여전히 ​​실패합니다. –

+0

@pythonscript'SudokuWindow'는 클래스에'CellBlock'을 가지고 있지 않기 때문에 ... 네임 스페이스와 클래스가 다르기 때문에 리팩터링을해야 생성 된 코드가 ... namespace.CellBlock()'- 그리고 미래의 상황에서이 상황을 피하기 위해 패키지 이름을 고유하게 유지할 것입니다. – user12345613

+0

맞습니다. 그 줄을 손으로 바꾸는 것을 주저하는 이유는 (나는 클래스를 다시 팩할 때 * 그 줄을 업데이트하지 않기 때문에해야 할 것이다.) 나는 designer.cs 파일을 직접 변경하고 싶지 않다. . 클래스를 다시 팩터링하면 문제의 행이 변경되며 이는 여전히 올바르지 않습니다. 네임 스페이스를 다시 고려하면 수동으로 변경하지 않으면 해당 줄이 변경되지 않으므로 문제가 해결되지 않습니다. –

관련 문제