troubleshooting Question

Add Combobox column to datagridview using vb.net

Avatar of Mike_Stevens
Mike_StevensFlag for United States of America asked on
Visual Basic.NET* DataGridView
2 Comments1 Solution221 ViewsLast Modified:
I have a winform that has a datagridview  and i am formatting the layout of the grid using using the following vb.net code.   I would like to have column 2 in the grid be a combobox column.   How can i change column from a textbox to a combobox using my existing code.

With Me.Datagridview1

             .AllowUserToAddRows = True
            .AllowUserToDeleteRows = True
            .AllowUserToOrderColumns = False
            .AllowUserToResizeColumns = False
            .AllowUserToResizeRows = False
            .AutoGenerateColumns = False

            .Columns(1).Width = 175
            .Columns(1).DataPropertyName = "Car_Color"
            .Columns(1).HeaderText = "Car Color"
            .Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
            .Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft

             .Columns(2).Width = 175
            .Columns(2.DataPropertyName = "Interior_Color"
            .Columns(2).HeaderText = "Interior Color"
            .Columns(2).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
            .Columns(2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft

End With
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros