By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

Populate DataGridVieComboBox with adaptable

P: 54
Please I have DatagridView bound to a DataTable
that pulls records and displays the DataGridView
correctly. Now, I have ColumnType as
DataGridViewComboBoxColumn 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.

Expand|Select|Wrap|Line Numbers
  1. 'Objects already initialized
  2. Dim QueryU As String = "select * from Users
  3. where username='" & frmUsers.txtUsername.Text
  4. & "'"
  5. Dim daUser As New SqlDataAdapter
  6. (QueryU, SQLCon)
  7. Dim dtUser As New DataTable
  8. daUser.Fill(dtUser)
  9. If dtUser.Rows.Count > 0 Then
  10. Dim c4 As New DataGridViewComboBoxColumn()
  11. c4.HeaderText = "Send To"
  12. c4.Name = "Username"
  13. c4.DataPropertyName =
  14. "Username"
  15. c4.DisplayMember =
  16. "Username"
  17. c4.ValueMember =
  18. "Username"
  19. c4.DisplayStyleForCurrentCellOnly = False
  20. c4.DisplayStyle =
  21. DataGridViewComboBoxDisplayStyle.Nothing
  22. c4.FlatStyle =
  23. FlatStyle.Popup
  24. c4.SortMode =
  25. DataGridViewColumnSortMode.Automatic
  26. c4.DataSource = dtUser
  27. c4.Width = 300
  28. frmUsers.DataGridView1.Columns.Add(c4)
  29.  
Oct 22 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.