Dim i As String For Each i In Chklistbox.CheckedItems Me.DataGrid1.DataSource = Chklistbox.CheckedItems Next
For Each colonne In table.Columns Fdepre.Chklistbox.Items.Add(colonne.ColumnName()) Next
Me.DataGrid1.DataSource = table
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub CopyTableInDatagridview()
'Copie le datatable dans le datagridview
DataGrid1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Sunken
DataGrid1.Font = New Font("arial", 14, FontStyle.Bold, GraphicsUnit.Pixel)
DataGrid1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
DataGrid1.EnableHeadersVisualStyles = False
DataGrid1.ColumnHeadersDefaultCellStyle.BackColor = Color.PowderBlue
Dim bds As New BindingSource
bds.DataSource = table
DataGrid1.DataSource = bds
DataGrid1.AutoSize = True
DataGrid1.AutoResizeColumns()
End Sub
For iter = 0 To CheckedListBox1.Items.Count - 1
If CheckedListBox1.GetItemChecked(iter) = False Then
DataGrid1.Columns(CheckedListBox1.Items(iter).ToString).Visible = False
End If
Next
For Each item In CheckedListBox1.Items
If Not CheckedListBox1.CheckedItems.Contains(item) Then
DataGrid1.Columns(item.ToString).Visible = False
End If
Next
DataGrid1.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)
DataGrid1.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)