Combobox column in datagridview

Mondeo

Centurion
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
Hi,

I have a simple datagridview generated dynamically

Friend WithEvents dgMemberNotes as DataGridView
dgMemberNotes.DataSource = db.GetDataSet("SELECT staff,comment,dtime FROM membernotes").Tables(0)

It works fine, however is it possible I can make column 1 a combobox, with selections from another query. i.e. SELECT staffname FROM staffmembers?

Thanks
 
Okay i've done this before the databinding

dgMemberNotes.Columns.Add(New DataGridViewComboBoxColumn)
dgMemberNotes.Columns.Add(New DataGridViewTextBoxColumn)
dgMemberNotes.Columns.Add(New DataGridViewTextBoxColumn)

But now my datagrid contains 6 columns, these 3 plus the 3 in generates automatically.

How do I get it to use the 3 columns i've created manually?
 
If you don't want to use the autogenerated columns then you can set the AutoGeneratedColumns property to false.

To bind the ComboBox column, you set it's DataSourceID (you may use DataSource property too, if you want).

For example something like that.
YourComboBoxColumn.DataSource = db.GetDataSet("your_second_query").Tables(0)
 
I added the combobox column from design view, and If I do
dg.columns("ComboColumn").DataSource there's no such field as DataSource

How can I access the combobox from a comboboxColumn, I would preffer to set the value for each one, one by one.

(Because Later i'll need to read those values)
 
Back
Top