1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dt As DataTable = New DataTable()
dt.Columns.Add("name")
For j As Integer = 0 To 10 - 1
dt.Rows.Add("")
Next
Me.DataGridView1.DataSource = dt
Me.DataGridView1.Columns(0).Width = 200
Dim ComboBoxCell As DataGridViewComboBoxCell = New DataGridViewComboBoxCell()
ComboBoxCell.Items.AddRange(New String() {"aaa", "bbb", "ccc"})
Me.DataGridView1(0, 0) = ComboBoxCell
Me.DataGridView1(0, 0).Value = "bbb"
Dim TextBoxCell As DataGridViewTextBoxCell = New DataGridViewTextBoxCell()
Me.DataGridView1(0, 1) = TextBoxCell
Me.DataGridView1(0, 1).Value = "some text"
Dim CheckBoxCell As DataGridViewCheckBoxCell = New DataGridViewCheckBoxCell()
CheckBoxCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
Me.DataGridView1(0, 2) = CheckBoxCell
Me.DataGridView1(0, 2).Value = True
Dim dtp As DateTimePicker = New DateTimePicker()
dtp.Value = DateTime.Now.AddDays(-10)
Me.DataGridView1.Controls.Add(dtp)
dtp.Location = Me.DataGridView1.GetCellDisplayRectangle(0, 3, True).Location
dtp.Size = Me.DataGridView1.GetCellDisplayRectangle(0, 3, True).Size
End Sub |
Partager