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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Enum ColumnName
CustomerID
CustomerName
StoreID
StoreName
ProductID
ProductName
Nom_Produit
End Enum
Private Function CreateComboBoxColumn() _
As DataGridViewComboBoxColumn
Dim column As New DataGridViewComboBoxColumn()
With column
.DataPropertyName = ColumnName.ProductID.ToString()
.HeaderText = ColumnName.Nom_Produit.ToString()
.DropDownWidth = 160
.Width = 265
.MaxDropDownItems = 9
.FlatStyle = FlatStyle.Popup
.AutoComplete = True
End With
Return column
End Function
Private Sub SetAlternateChoicesUsingDataSource( _
ByVal comboboxColumn As DataGridViewComboBoxColumn)
With comboboxColumn
.DataSource = RetrieveAlternativeTitles()
.ValueMember = ColumnName.ProductID.ToString()
.DisplayMember = ColumnName.ProductName.ToString()
.AutoComplete = True
End With
End Sub
Private Function RetrieveAlternativeTitles() As DataTable
Return Populate( _
"SELECT distinct ProductID, ProductName FROM ArchReportStock ORDER BY ProductName")
End Function
Private Sub SetAlternateChoicesUsingDataSource2( _
ByVal comboboxColumn2 As DataGridViewComboBoxColumn)
With comboboxColumn2
.DataSource = RetrieveAlternativeTitles2()
.ValueMember = ColumnName.ProductID.ToString()
.DisplayMember = ColumnName.ProductName.ToString()
End With
End Sub
Private Function RetrieveAlternativeTitles2() As DataTable
Return Populate( _
"SELECT distinct ProductID, ProductName, StoreID FROM ArchStockSetUp ORDER BY ProductName")
End Function
Private connectionString As String = My.Settings.PharmaDataConnectionString
Private Function Populate(ByVal sqlCommand As String) As DataTable
Dim PharmaDataConnectionString As New SqlConnection(connectionString)
PharmaDataConnectionString.Open()
Dim command As New SqlCommand(sqlCommand, _
PharmaDataConnectionString)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = command
'fill the dataset
'pour memoire dataset n a aucune liaison avec la bd
'c est le dataAdapter qui le fill avec les données
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
adapter.Fill(table)
Return table
End Function
#End Region |
Partager