Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Populate Combobox in Datagridview Control

Posted on 2007-04-04
2
Medium Priority
?
1,425 Views
Last Modified: 2010-08-05
VB 2005

I am trying to populate a combobox in a Datagridview control with data from an arraylist.  I can't figure out how to bind the arraylist to the combobox.

The combobox is in the first cell of the Datagridview.

Does anyone know how to do this?

Thanks

RichW
0
Comment
Question by:RichW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 18851884
You could do something like this:

Dim comboboxColumn As New DataGridViewComboBoxColumn()
comboboxColumn.DataPropertyName = "ptitle"
comboboxColumn.HeaderText = "Title"
comboboxColumn.DropDownWidth = 50
comboboxColumn.Width = 50
comboboxColumn.MaxDropDownItems = 5
comboboxColumn.FlatStyle = FlatStyle.Flat

Dim dbComboCommand As New OleDbCommand()
dbComboCommand.Connection = dbConn
dbComboCommand.CommandText = "SELECT title FROM Titles"
Dim dbComboDA As New OleDbDataAdapter(dbComboCommand)
Dim Cds As New DataSet()
dbComboDA.Fill(Cds, "results")

comboboxColumn.DataSource = Cds.Tables[0]
comboboxColumn.ValueMember = "title"
comboboxColumn.DisplayMember = comboboxColumn.ValueMember

dataGridView1.Columns.Insert(1, comboboxColumn)

Bob
0
 
LVL 4

Author Comment

by:RichW
ID: 18852114
Thanks LearnedOne.  Exactly what I was looking for.

RichW
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question