c# - LookUpEdit not selecting newly entered value when it's a double -
i have 2 lookupedit controls devexpress on form. both use observablecollection
it's datasource, 1 being of type string
, other of type double
. lookupedit control has event called processnewvalue
fires when, guessed it, new value entered in control. i've added code in event add newly added value observablecollection
, automatically selects once done. works expected string
looupedit when try double
lookupedit`, adds collection clears out control.
here's code load controls, gets called in form_load()
:
void initcontrols() { double[] issuenumbers = new double[5]; issuenumbers[0] = 155; issuenumbers[1] = 156; issuenumbers[2] = 157; issuenumbers[3] = 158; issuenumbers[4] = 159; observablecollection<double> issues = new observablecollection<double>(issuenumbers); lookupissues.properties.datasource = issues; devexpress.xtraeditors.controls.lookupcolumninfocollection colinfo = lookupissues.properties.columns; colinfo.clear(); colinfo.add(new devexpress.xtraeditors.controls.lookupcolumninfo("column")); colinfo[0].caption = "issue id's"; string[] stringnumbers = array.convertall<double, string>(issuenumbers, convert.tostring); observablecollection<string> issuesstring = new observablecollection<string>(stringnumbers); lookupstringvalue.properties.datasource = issuesstring; colinfo.clear(); colinfo.add(new devexpress.xtraeditors.controls.lookupcolumninfo("column")); colinfo[0].caption = "string issue id's"; }
and here's processnewvalue event both (i've renamed them try make easier see what):
private void onprocessnewvalue_double(object sender, devexpress.xtraeditors.controls.processnewvalueeventargs e) { observablecollection<double> source = (observablecollection<double>)(sender lookupedit).properties.datasource; if (source != null) { if ((sender lookupedit).text.length > 0) { source.add(convert.todouble((sender lookupedit).text)); (sender lookupedit).refresh(); } } e.handled = true; } private void onprocessnewvalue_string(object sender, devexpress.xtraeditors.controls.processnewvalueeventargs e) { observablecollection<string> source = (observablecollection<string>)(sender lookupedit).properties.datasource; if (source != null) { if ((sender lookupedit).text.length > 0) { source.add((sender lookupedit).text); (sender lookupedit).refresh(); } } e.handled = true; }
as can see, code identical exception of 1 converting text double before adding collection.
anyone know why double value gets added collection control doesn't automatically select string collection? i've tried hard-code newly added value right after e.handled = true;
still doesn't select it. what's weird if run through debugger, can step through , see lookupissues
control indeed gets newly added value , it's text
property set it, event terminates, control clears out.....really strange.
any appreciated!
btw, can add link sample project duplicates problem need have devexpress v12.2.6 controls installed in order compile project.
i posted devexpress team , gracious enough provide solution:
i agree discrepancy appears confusing as-is. reason discrepancy lookupedit.processnewvaluecore makes call repositoryitemlookupedit.getkeyvaluebydisplayvalue returns null value lookuplistdataadapter because no implicit conversion exists double string. may resolve discrepancy following change processnewvalue handler:
private void onprocessnewvalue_double(object sender, devexpress.xtraeditors.controls.processnewvalueeventargs e) { observablecollection<double> source = (observablecollection<double>)(sender lookupedit).properties.datasource; if (source != null) { if ((sender lookupedit).text.length > 0) { double val = convert.todouble((sender lookupedit).text); source.add(val); e.displayvalue = val; (sender lookupedit).refresh(); } } e.handled = true; }
the control behaves expected. hope can else out :)
Comments
Post a Comment