Populate DataGridVieComboBox with adaptable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Benniit
    New Member
    • May 2008
    • 54

    Populate DataGridVieComboBox with adaptable

    Please I have DatagridView bound to a DataTable
    that pulls records and displays the DataGridView
    correctly. Now, I have ColumnType as
    DataGridViewCom boBoxColumn of the forth
    column named "Username". When I click the
    combo box of the DataGridview, nothing gets
    displayed at all. I just don't understand it.
    Below is the code.

    Code:
    'Objects already initialized
    Dim QueryU As String = "select * from Users
    where username='" & frmUsers.txtUsername.Text
    & "'"
    Dim daUser As New SqlDataAdapter
    (QueryU, SQLCon)
    Dim dtUser As New DataTable
    daUser.Fill(dtUser)
    If dtUser.Rows.Count > 0 Then
    Dim c4 As New DataGridViewComboBoxColumn()
    c4.HeaderText = "Send To"
    c4.Name = "Username"
    c4.DataPropertyName =
    "Username"
    c4.DisplayMember =
    "Username"
    c4.ValueMember =
    "Username"
    c4.DisplayStyleForCurrentCellOnly = False
    c4.DisplayStyle =
    DataGridViewComboBoxDisplayStyle.Nothing
    c4.FlatStyle =
    FlatStyle.Popup
    c4.SortMode =
    DataGridViewColumnSortMode.Automatic
    c4.DataSource = dtUser
    c4.Width = 300
    frmUsers.DataGridView1.Columns.Add(c4)
Working...