2017-04-18 3 views
1

私のソフトウェアでグラフィカルグリッチが報告された後、サンプルプロジェクトを作成しましたが、問題を容易に再現できました。私は、フォームでの簡単なドッキングのDataGridViewを作成して、私はこのようなランダムデータでそれを埋める:DataGridViewのグラフィカルグリッチ

var ds = new DataSet(); 
var table = ds.Tables.Add(); 
Enumerable.Range(0, 100).ForEach(i => table.Columns.Add(i.ToString())); 

Enumerable.Range(0, 100).ForEach(i => 
{ 
    var row = table.NewRow(); 
    Enumerable.Range(0, 100).ForEach(j => row[j.ToString()] = Guid.NewGuid().ToString()); 
    table.Rows.Add(row); 
}); 

dataGridView1.DataSource = table; 

今私は、私のプログラムを起動し、それの一部が私のタスクバーで覆われているように、ウィンドウを移動し、スクロールバーを使用します。突然、すべてのデータが台無しにされています

UPDATE:

partial class Form1 
{ 
    /// <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 Windows Form 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.dataGridView1 = new System.Windows.Forms.DataGridView(); 
     ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); 
     this.SuspendLayout(); 
     // 
     // dataGridView1 
     // 
     this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 
     this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; 
     this.dataGridView1.Location = new System.Drawing.Point(0, 0); 
     this.dataGridView1.Name = "dataGridView1"; 
     this.dataGridView1.Size = new System.Drawing.Size(986, 758); 
     this.dataGridView1.TabIndex = 0; 
     // 
     // Form1 
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.ClientSize = new System.Drawing.Size(986, 758); 
     this.Controls.Add(this.dataGridView1); 
     this.Name = "Form1"; 
     this.Text = "Form1"; 
     ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); 
     this.ResumeLayout(false); 

    } 

    #endregion 

    private System.Windows.Forms.DataGridView dataGridView1; 
} 

enter image description here

この背後にある理由は何ですか?

+0

上記のコードはいつ実行されますか? – Alex

+0

@Alexデザイナを介してフォームにドッキングされたDataGridViewにデータを追加します。これはフォームのコンストラクタで発生します。 –

+0

質問は「なぜ」ではなく「いつ」ですか。このメソッドが呼び出されるときの、どのメソッドの内部。私はそれが複数回実行されていないかどうかを確認するためにブレークポイントを設定します。 – Alex

答えて