Reputation: 4997
I have a datagridview combo box column with Read Only property set to False. I need to insert values to the combo box (say One, Two, Three etc.) and also I need the combo box to display a certian value stored in a variable (say dim abc as string="value")
I need the combo box to display value stored in abc when the form loads.
Please advise how to achieve these two tasks.
Thanks
Upvotes: 0
Views: 302
Reputation:
Combobox-type DataGridView
cells/columns are, by default, read-only
(users cannot change their items). Sample code to start a DataGridView1
with a combobox-type column, populated with the values you wish:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim curCol As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
Dim abc As String = "value"
Dim items As List(Of String) = New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add(abc)
curCol.DataSource = items
DataGridView1.Columns.Add(curCol)
End Sub
Upvotes: 1