what i did is bind a datagridview combobox column to a datasource
(1) put 3 bindingsource controls on form
(3) binded to different dataset -> datatables ( untyped )
(3) binded the combobox column of the datagridview to binding sources
(4) at the last i have set the data property + datasource of the datagridview ( manually created the columns autogenerate columns is set to false )
the error is :-
system.formateception
datagridview combobox cell value is not valid
Code used to bind the bindingsource / combobox column
bind the datagrid view to another binding source
........ Continued
(1) put 3 bindingsource controls on form
(3) binded to different dataset -> datatables ( untyped )
(3) binded the combobox column of the datagridview to binding sources
(4) at the last i have set the data property + datasource of the datagridview ( manually created the columns autogenerate columns is set to false )
the error is :-
Quote:
system.formateception
datagridview combobox cell value is not valid
vb.net Code:
Private Sub BindGridCombo_Depots() Dim SQL_bind = <sql>SELECT stationregistry.StationName as CrewDepot, depot_config.DepotId FROM stationregistry INNER JOIN depot_config ON stationregistry.StationId = depot_config.StationId_Fk WHERE stationregistry.CrewBase = "Y" ; </sql> Dim S As String = SQL_bind.Value.ToString Dim Cnn896 As New MySqlConnection Dim Cmd896 As New MySqlCommand(S, Cnn896) Dim Da896 As New MySqlDataAdapter(Cmd896) Dim Ds896 As New DataSet Dim Cnm As New ConnectionManager Cnm.InitializeConnectionProperty(Cs) Dim Dt_Sepot As New DataTable With Da896 Cnm.Connect(Cnn896) .Fill(Ds896, "Container") Cnm.DisConnect(Cnn896) .Dispose() Cmd896.Dispose() End With Dt_Sepot = Ds896.Tables("Container") Ds896.Dispose() With Me.Depot_Source .DataSource = Dt_Sepot End With With Me.Dgv_CrewDetail Me.DepotCombo.ValueType = GetType(String) Me.DepotCombo.DataPropertyName = "StationName" Me.DepotCombo.DisplayMember = "CrewDepot" Me.DepotCombo.ValueMember = "DepotId" Me.DepotCombo.DataSource = Depot_Source End With End Sub
vb.net Code:
Private Sub Bind_FullGrid() Dim SQL_bind = <sql>SELECT crewregistry.CrewName, crewregistry.Designation, stationregistry.StationName, crewregistry.CugNumber, crewregistry.PerNumber, crewregistry.CRISid, lidata.LIname, crewregistry.Inactive, crewregistry.CrewId FROM crewregistry INNER JOIN depot_config ON crewregistry.CrewBaseId_Fk = depot_config.DepotId INNER JOIN stationregistry ON depot_config.StationId_Fk = stationregistry.StationId INNER JOIN lidata ON crewregistry.NliId_Fk = lidata.LiId; </sql> Dim S As String = SQL_bind.Value.ToString Dim Cnn896 As New MySqlConnection Dim Cmd896 As New MySqlCommand(S, Cnn896) Dim Da896 As New MySqlDataAdapter(Cmd896) Dim Ds896 As New DataSet Dim Cnm As New ConnectionManager Cnm.InitializeConnectionProperty(Cs) Dim Dt_FullGrid As New DataTable With Da896 Cnm.Connect(Cnn896) .Fill(Ds896, "Container") Cnm.DisConnect(Cnn896) .Dispose() Cmd896.Dispose() End With Dt_FullGrid = Ds896.Tables("Container") Ds896.Dispose() With Me.S_fullGridBiner .DataSource = Dt_FullGrid End With With Me.Dgv_CrewDetail .DataSource = S_fullGridBiner End With End Sub
vb.net Code:
Private Sub CrewBiodata_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Dgv_CrewDetail.AutoGenerateColumns = False '' Columns + DataProperty name of columns set at design time Me.Dgv_CrewDetail.AllowUserToAddRows = True Call BindGridCombo_Depots() '' Call BindGridCombo_Li() '' Bind another combobox column Call Bind_FullGrid() '' data property of the columns are set in design time End Sub