Click here to Skip to main content
15,910,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a datagridviewcombobox added programmatically. How can I set a default value for each row. I would like the default value to be "No"

Dim dt As New DataTable("tblFirstDatagrid")
               dt.Columns.Add("Passed?")
               dt.LoadDataRow(New Object() {"Yes"}, True)
               dt.LoadDataRow(New Object() {"No"}, True)
               dt.LoadDataRow(New Object() {"NA"}, True)
               .dgTroubleshootingandResolution.DataSource = dt
               .dgTroubleshootingandResolution.AllowUserToAddRows = False
               .dgTroubleshootingandResolution.Columns.Remove("Passed?")
               Dim cmb As New DataGridViewComboBoxColumn
               With cmb
                   .Items.Add("Yes")
                   .Items.Add("No")
                   .Items.Add("NA")
                   .DataPropertyName = "Passed?"
                   .HeaderText = "Passed?"
                   .Name = "Passed?"
               End With
               .dgTroubleshootingandResolution.Columns.Add(cmb)


I've tried the code below but it's still not working.

What I have tried:

dt.Columns("Passed?").DefaultValue = "No"
Posted
Updated 7-Sep-17 8:46am

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900