vb.net - Combobox selected Item does not match with its selected -
i faced issue appears spaces after letters finished more combobox.selecteditem's length. why? how can fix issue?
below showing issue visual short , small video. here small video
imports system.data.sqlclient public class main withevents bsdata new bindingsource dim sconn new sqlconnection dim dt new datatable dim ds new dataset private sub main_load(sender object, e eventargs) handles mybase.load sconn.connectionstring = "data source=pc-n39;initial catalog=esi01;persist security info=true;user id=sa;password=sas" sconn.open() try dim mytable datatable = new datatable("mytable") mytable.columns.add(new datacolumn("group code")) mytable.columns.add(new datacolumn("description")) mytable.columns.add(new datacolumn("nothingserious")) dim cmd new sqlcommand("select * tbunit", sconn) dim dr sqldatareader = cmd.executereader(commandbehavior.default) dim myrow datarow while dr.read() myrow = mytable.newrow myrow.item(0) = dr(0) myrow.item(1) = dr(1) myrow.item(2) = dr(2) mytable.rows.add(myrow) end while dr.close() dim mydata4 datatable = mytable ds = new dataset() ds.tables.add(mydata4) multicolumncombo1.displaymember = "group code" multicolumncombo1.drawmode = drawmode.ownerdrawvariable multicolumncombo1.columnwidths = "50;150" multicolumncombo1.datasource = mydata4 multicolumncombo1.text = string.empty catch ex exception msgbox(ex.tostring) end try sconn.close() end sub end class
what type multicolumncombo1 ? suppose it's third party component. far can see in video, seems takes biggest element in data, take it's length , add spaces other elements make them same size.
you won't able change component's behavior, can apply same logic enter in textbox
: adding spaces make them match. or if need make condition test if equal, can follow :
if(yourcomboboxselecteditem.trim() == stringyourarecomparingitto)
see string.trim(), discard whitespaces.
Comments
Post a Comment