2013年5月23日木曜日

DataGridViewComboBoxColumnの初期値を入れる

DataGridViewComboBoxColumnの初期値を入れる

①まず、DataGridViewのCellFormattingイベントハンドラを追加
②そのイベントハンドラの中、下記を追加
  例の中、DataGridViewComboBoxColumnは第二列にある。
  
Private Sub m_dgvData_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles m_dgvData.CellFormatting
        If e.ColumnIndex = 1 Then ' Index of your DataGridViewComboBoxColumn 
            CType(m_dgvData.Rows(e.RowIndex).Cells(1), DataGridViewComboBoxCell).Value = 1
        End If
    End Sub

0 件のコメント:

コメントを投稿