Link to home
Start Free TrialLog in
Avatar of Mike_Stevens
Mike_StevensFlag for United States of America

asked on

Add Combobox column to datagridview using vb.net

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
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike_Stevens

ASKER

Thanks Ryan...thats exactly what i was looking for.

Thank you!