2012-03-23 12 views
0

が、私は6列のデータグリッドを持ちました私はDataGridの最後の行のparamsを設定し、新しい行を追加された機能を書いてきましたC#移入DataGridのコンボボックス、チェックボックスとテキストボックス

public class GridLine 
    { 
    public string sColumnA { get; set; } 
    public bool bError { get; set; } 
    public string sColumnB { get; set; } 
    public bool bNullableB { get; set; } 
    public bool bCollateB { get; set; } 
    public bool bStaticB { get; set; } 
    public string sStaticB { get; set; } 
    (...) 
    } 

グリッド線のリストでm個の保持は、オブジェクトが、正しく動作していない - 私は最後の行が正しく設定上の唯一のコンボボックスを取得しています、その他:

 private void AddLine(GridLine gl) 
    { 
     DataGridViewComboBoxCell cellMs = (DataGridViewComboBoxCell)this.Rows[this.Rows.Count - 1].Cells[0]; 
     DataGridViewComboBoxCell cellOra = (DataGridViewComboBoxCell)this.Rows[this.Rows.Count - 1].Cells[1]; 
     DataGridViewCheckBoxCell cellNull = (DataGridViewCheckBoxCell)this.Rows[this.Rows.Count - 1].Cells[2]; 
     DataGridViewCheckBoxCell cellColl = (DataGridViewCheckBoxCell)this.Rows[this.Rows.Count - 1].Cells[3]; 
     DataGridViewCheckBoxCell cellStat = (DataGridViewCheckBoxCell)this.Rows[this.Rows.Count - 1].Cells[4]; 
     DataGridViewTextBoxCell cellStatText = (DataGridViewTextBoxCell)this.Rows[this.Rows.Count - 1].Cells[5]; 

     cellMs.Value = gl.sColumnA; 
     cellOra.Value = gl.sColumnB; 
     cellNull.Selected = gl.bNullableB; 
     cellColl.Selected = gl.bCollateB; 
     cellStat.Selected = gl.bStaticB; 
     cellStatText.Value = gl.sStaticB; 

     this.Rows.Add(); 
    } 

私は何が間違っているのか分かりません。

感謝

答えて

0

はあなたのDataGridViewに追加したい項目(グリッド線)の結合リストhttp://msdn.microsoft.com/en-us/library/ms132679.aspxを作成してみてください。次に、DataGridのプロパティDataSourceにそのリストを割り当てます。

これを行う前に、デザイナーの列をdatagridviewに追加する必要があります。

詳細情報はこちらhttp://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx

関連する問題