Click here to Skip to main content
14,981,532 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys..
i have adatagrid with DataGridComboBoxColumn and i want to fill this combobox with two items ,
can any one hwlp me in doing that
Updated 9-Nov-18 1:42am

You define the ItemsSource for the combo box.

Here's one example[^]
Public Property Warehouse() As ObservableCollection(Of String)
Function loadWarehouse()
Dim a As String
Dim dbConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
Dim ConString As String = ConfigurationManager.ConnectionStrings("CompuTrakwpf.MySettings.CompuTrakDBConnectionString").ConnectionString
dbConn.ConnectionString = ConString : dbConn.Open()
Dim DSet As New DataSet, SQLStr As String
Dim cmd As System.Data.SqlClient.SqlCommand
Dim dbAdaptr As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
Dim tRow As DataRow, tTbl As DataTable
With dbAdaptr
.TableMappings.Add("Table", "Warehouse")
SQLStr = "Select [Warehouse] from [Warehouse] order by [Warehouse]"
cmd = New System.Data.SqlClient.SqlCommand(SQLStr, dbConn)
cmd.CommandType = CommandType.Text
.SelectCommand = cmd
End With
tTbl = DSet.Tables.Item(0)
DSet.Dispose() : dbConn.Close()
Warehouse = New ObservableCollection(Of String)() From {""}
For Each tRow In tTbl.Rows
a = (tRow("Warehouse").ToString)
Return 0
Catch ex As Exception
End Try
End Function

<DataGridComboBoxColumn x:Name="cboWarehouse" Header="Warehouse" Width="70" SelectedItemBinding="{Binding WareHouse}"/>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900