Mondeo Posted November 19, 2006 Posted November 19, 2006 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 Quote
dinoboy Posted November 20, 2006 Posted November 20, 2006 If you manually create the DataGridView columns, then you can add a ComboBoxColumn and bind it to that query. Quote
Mondeo Posted November 20, 2006 Author Posted November 20, 2006 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? Quote
Mondeo Posted November 20, 2006 Author Posted November 20, 2006 Think i've got it, setting the DataPropertyName of the column Last question, how do I bind that second query to the column? Thanks Quote
dinoboy Posted November 20, 2006 Posted November 20, 2006 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) Quote
PROKA Posted November 29, 2006 Posted November 29, 2006 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) Quote Development & Research Department @ Elven Soft
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.