Bonjour,
Je voudrai savoir la difference qui existe entre le datagridviewcomboboxcell et datagridviewcomboboxcolumn
Version imprimable
Bonjour,
Je voudrai savoir la difference qui existe entre le datagridviewcomboboxcell et datagridviewcomboboxcolumn
Bonjour
datagridviewcomboboxcolumn est un des types de la colonne
peut être
datagridviewcomboboxcell pour modifiier une cellule de la colonne
ex
Code:
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 Public Class Form1 Private WithEvents button As New Button Private DGV As New DataGridView Private Sub init() 'crée une colonne de type DataGridViewComboBoxColumn chaque combo contient item0 item1 ...item10 Dim col1 As New DataGridViewComboBoxColumn With col1 .Name = "combo" For iter = 0 To 10 .Items.Add("items" & iter) Next End With DGV.Columns.Add(col1) DGV.Columns("combo").DefaultCellStyle.Font = New Font("arial", 12, FontStyle.Bold) For iter = 0 To 9 DGV.Rows.Add() Next DGV.AutoResizeColumns() DGV.AutoSize = True Me.Controls.Add(DGV) End Sub Private Sub change() 'modifier tous les deuxièmes combo avec comboCell For iter = 1 To DGV.Rows.Count - 1 Step 2 Dim comboCell As New DataGridViewComboBoxCell For iter1 = 0 To 10 comboCell.Items.Add("TOTO" & iter1.ToString) Next DGV.Rows(iter).Cells("combo") = comboCell Next End Sub Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load Me.Controls.Add(button) button.Text = "modifier" button.Location = New Point(10, 10) init() DGV.Location = New Point(50, button.Bottom + 10) End Sub Private Sub button_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles button.MouseClick change() End Sub End Class