Eyo 0 Newbie Poster

Hello,

I have a problem when adding a comboBox Cell to grdView

I Attached The Error Message, please have a time to view it

And Here Is Some Parts Of The Code:

' Start ...

dim colComboBox As New DataGridViewComboBoxColumn

Sub Form_Load()

configureColComboBox()
fillGrid()

bindComboBoxColumn("company_id",colComboBox)
End Sub

Sub confingureColComboBox()

with
.DataPropertyName ="company_id"
.DataSource = GetDataTable()
.DisplayMember = "name"
.ValueMember ="id"
.Name = "company_id"
End with

End Sub
'------------------------------------------------
Sub fillGrid()

con.open()
dim query As String = "SELECT id,emp_name, company_id FROM Emp_Tbl"
mycommand = new sqlCommnad(query,con)

dim da as SqlDataAdapter
dim dt As new DataTable

da.selectedCommand = mycommand

da.Fill(dt)

grdView.datasource = dt

End sub
'----------------------------------------------------
Function GetDataTable() AS DataTable
con.open

dim query as string ="SELECT id,name From Com_Tbl "
mycommand = new sqlCommand(query,con)

dim da As SqlDataAdapter
dim dt as new DataTable

da.selectcommand = mycommand
da.Fill(dt)

return dt

End Function
'-----------------------------------------------
Sub bindComboBoxColumn(colName As string,newCol AS _ DataGridViewComboBoxColumn)

Dim loc As Integer = grdViewVisaDetails.Columns.IndexOf(grdViewVisaDetails.Columns(colName))
grdViewVisaDetails.Columns.RemoveAt(loc)
grdViewVisaDetails.Columns.Insert(loc, newCol)

End Sub