Saturday, 15 August 2015

DataGridView ComboBoxCell is not showing values that are not from the list vb.net -


Hello, I have a combo box which is well populated by a binding source. The problem is that the data grid "name" column is showing only those values ​​that come from the populated drop down list. Values ​​that are not similar to the droplist appear blank. Can someone tell me why? Below is a code for Cambodia. I can not print prints, but the description is like this. There are 3 names in the list: John, Jake, J. But the column has more than 10 names, each has its own related cell problem when it is not showing other names onload.

  dim C4 New DataGridViewComboBoxColumn (as) c4.HeaderText = "name" c4.Name = "name" c4.DataPropertyName = "name" C4.DisplayMember = "namesWithJ" c4. ValueMember = "nameswithJ" c4.DisplayStyleForCurrentCellOnly = False c4.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing c4.FlatStyle = FlatStyle.Standard c4.SortMode = DataGridViewColumnSortMode.Automatic c4.DataSource = AddtBndSrc c4.Width = 100 Me.DataGrid.Columns.Add (C 4)   

And here's the code where I can create bindingsource and fill it with the value. There is no error with the connection, which looks like a whole Some of the comboboxcolumn lines

  try to con = new SqlConnection (strConnection) cib.Open () adoAAda = new SqlDataAdapter ( StrAddNameQuery, con) adoAddtRs = new dataset showing null adoAAda just that .Fill (adoAddtRs) dim tableAddt DataTable = adoAddtRs.Tables (0) DataColumn as dim colum = tableAddt.Columns (0) tableAddt.PrimaryKey = new DataColumn () {tableAddt.Columns (0)} AddtBndSrc.DataSource = adoAddtRs.Tables as (0) con.close () catch ex as exception MsgBox (ex.Message) termination letter Ryas Try connection process con = new SqlConnection (strConnection) con.Open () adoPAda = new SqlDataAdapter (StrProductQuery, con) adoProductsRS = new datasets adoPAda .Fill (adoProductsRS) Dim tableProduct DataTable = adoProductsRS.Tables (0) Dim colum as DataColumn = tableProduct.Columns (0) tableProduct.PrimaryKey = new DataColumn () {tableProduct.Columns (0)} productBndSrc.DataSource = adoProductsRS.Tables as (0) MsgBox (tableProduct.Columns (0) .ColumnName .ToString) con.close datagridview.Datasource = p roductBndSrc catching Try exception as former MsgBox (ex.Message) end    

you Ahte values ​​for Cambodia is hard for some combo but is pulled from the database. If you want to add hardcoded values ​​to the data source before compelling the combo, then you need to.

The following lines were given below code.

  adoAAda.Fill (adoAddtRs) tableAddt as DataTable = adoAddtRs.Tables (0) After Add dim   

'its hard coded name for the data source add binding before

  dim tableAddt as DataTable = adoAddtRs.Tables (0) dim dr DataRow = tableAddt.NewRow Dr. ( "NamesWithJ") = "My test 1" tableAddt.Rows.Add (Dr. ) in DataRow = tableAddt.NewRow as dim DR1 Dr. ( "NamesWithJ") = "Teblaedtkro as my test 2". Add (D1)    

No comments:

Post a Comment