windows - C# Unexpected behavior in DataGridView columns -
using visual studio, created data grid view allow users modify data. unfortunately, when application released executable, form seems add data in new columns instead of using designated ones. this:
error below
i not able replicate error in debug mode, here picture of how it's supposed look.
expected behavior below
here part of code gridview being created , populated.
//child name column datagridviewtextboxcolumn namecolumn = new datagridviewtextboxcolumn(); namecolumn.name = "cname"; namecolumn.headertext = "child name"; namecolumn.datapropertyname = "cname"; namecolumn.readonly = true; datagridview.columns.add(namecolumn); //child layer column var layercolumn = new datagridviewcomboboxcolumn(); layercolumn.name = "clayer"; layercolumn.headertext = "child layer"; layercolumn.datapropertyname = "clayer"; layercolumn.autocomplete = true; layercolumn.valuemember = "clayer"; layercolumn.valuetype = typeof(string); datagridview.columns.add(layercolumn); // parent name column datagridviewtextboxcolumn parentcolumn = new datagridviewtextboxcolumn(); parentcolumn.headertext = "parent name"; parentcolumn.name = "cparent"; parentcolumn.datapropertyname = "cparent"; parentcolumn.readonly = true; datagridview.columns.add(parentcolumn); //parent layer column var playercolumn = new datagridviewcomboboxcolumn(); playercolumn.name = "player"; playercolumn.headertext = "parent layer"; playercolumn.datapropertyname = "player"; playercolumn.autocomplete = true; playercolumn.valuemember = "player"; playercolumn.valuetype = typeof(string); datagridview.columns.add(playercolumn); //child name column datagridviewtextboxcolumn namecolumn2 = new datagridviewtextboxcolumn(); namecolumn2.name = "cname"; namecolumn2.headertext = "feat 1 name"; namecolumn2.datapropertyname = "cname"; namecolumn2.readonly = true; datagridview1.columns.add(namecolumn2); //child layer column var layercolumn2 = new datagridviewcomboboxcolumn(); layercolumn2.name = "clayer"; layercolumn2.headertext = "feat 1 layer"; layercolumn2.datapropertyname = "clayer"; layercolumn2.autocomplete = true; layercolumn2.valuemember = "clayer"; layercolumn2.valuetype = typeof(string); datagridview1.columns.add(layercolumn2); // parent name column datagridviewtextboxcolumn parentcolumn2 = new datagridviewtextboxcolumn(); parentcolumn2.headertext = "feat 2 name"; parentcolumn2.name = "cparent"; parentcolumn2.datapropertyname = "cparent"; parentcolumn2.readonly = true; datagridview1.columns.add(parentcolumn2); //parent layer column var playercolumn2 = new datagridviewcomboboxcolumn(); playercolumn2.name = "player"; playercolumn2.headertext = "feat 2 layer"; playercolumn2.datapropertyname = "player"; playercolumn2.autocomplete = true; playercolumn2.valuemember = "player"; playercolumn2.valuetype = typeof(string); datagridview1.columns.add(playercolumn2); _p = new processor(this); _characteristicviewmodels = new bindinglist<relativecharacteristicviewmodel>(); datagridview.datasource = _characteristicviewmodels; foreach (var c in characteristics) { foreach (var d in c.value) { _characteristicviewmodels.add(new relativecharacteristicviewmodel { cname = c.key.name, clayer = c.key.layer, cparent = d.name, player = d.layer }); } } datagridviewcomboboxcolumn clayercolumn = datagridview.columns["clayer"] datagridviewcomboboxcolumn; if (clayercolumn != null) { layers.foreach(p => clayercolumn.items.add(p)); } datagridviewcomboboxcolumn parentlayercolumn = datagridview.columns["player"] datagridviewcomboboxcolumn; if (parentlayercolumn != null) { layers.foreach(p => parentlayercolumn.items.add(p)); } _p = new processor(this); _characteristicviewmodels2 = new bindinglist<relativecharacteristicviewmodel>(); datagridview1.datasource = _characteristicviewmodels2; foreach (var c in characteristics2) { foreach (var d in c.value) { _characteristicviewmodels2.add(new relativecharacteristicviewmodel { cname = c.key.name, clayer = c.key.layer, cparent = d.name, player = d.layer }); } } datagridviewcomboboxcolumn clayercolumn2 = datagridview1.columns["clayer"] datagridviewcomboboxcolumn; if (clayercolumn2 != null) { layers.foreach(p => clayercolumn2.items.add(p)); } datagridviewcomboboxcolumn parentlayercolumn2 = datagridview1.columns["player"] datagridviewcomboboxcolumn; if (parentlayercolumn2 != null) { layers.foreach(p => parentlayercolumn2.items.add(p)); }
Comments
Post a Comment