Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridViewComboBoxCell
 

DataGridViewComboBoxCell

Hi..

I add combobox in datagridview in this way.

DataGridView1(1, index) = New DataGridViewComboBoxCell

CType(DataGridView1(1, index), DataGridViewComboBoxCell).Items.AddRange("1", "2", "3")

So now in the combobox Ican see 1, 2, 3 to choose from

but how can i do if i want "1" is from column 2 from "table" from Access database

And "2" is from column 3 from "table" from Access database and so on for "3" from column4?

I mean I dont want to add items manually but instead look up from the database and add accordingly?

Please help..

Thank you.

Pwint  Monday, December 11, 2006 2:07 AM

Hi,

You can add a DataGridViewComboBoxColumn to the grid and set the DataSource, DisplayMembers and ValueMembers properties.

Charles

cverdon  Monday, December 11, 2006 2:16 AM

Now i did

CType(DataGridView1(1, index), DataGridViewComboBoxCell).Items.AddRange(CType(ds.Tables(0).Rows(0).Item(6), String))

to fill up the dataset but i can only fill up column(6) data. If I want column(7) data as wellto a comboboxlist, how can I able to do it?

Pwint  Monday, December 11, 2006 3:00 AM

if i do this

CType(DataGridView1(1, index), DataGridViewComboBoxCell).Items.AddRange((CType(ds.Tables(0).Rows(0).Item(6), String)), (CType(ds.Tables(0).Rows(0).Item(7), String)))

i get this error...

Conversion from type 'DBNull' to type 'String' is not valid.

Need help.

Pwint  Monday, December 11, 2006 3:11 AM

Dim S As New CostingDataSetTableAdapters.CurrenciesTableAdapter

S.Fill(Me.CostingDataSet.Currencies)

CType(DataGridView1(1, 0), _

DataGridViewComboBoxCell).Items.AddRange( _

Me.CostingDataSet.Currencies(0).CurrencyName, _

Me.CostingDataSet.Currencies(1).CurrencyName)

i could not simulate a same situation with a typed dataset.

you could be doing one of these:

not filling table.,

the row contains a null value at this position.

or something similar.....

hrubesh  Tuesday, December 12, 2006 10:36 AM

You can use google to search for other answers

Custom Search

More Threads

• adding date columns and time rows to a datagridview
• transfer data between/to forms
• Datagridview cell coloring problem
• 2 comboboxes in relation , inside a datagridview
• DataGrid Expand problem
• DataGridView with frequently updated DataSource
• Way to batch add records from a bindingSource
• Keyword not supported: 'provider'.
• Populating a list box from a combobox selecton
• How should I resize the datagrid