Delphi TValueListEditor Strings prop-ed quirk? -


investigating odd behaviour of tvaluelisteditor being used generate filter expression clientdataset, i've traced situation if first entry in apparently had nothing in value column, returned #13#10 value, rather ''.

in following, tstringlist tl initialized same contents valuelisteditor strings property has in app. assert not fail tstringlist, valuelisteditor. these results occurred d7 , xe4.

procedure tdefaultform.applyfilter; var   i,   max : integer;   key,   value : string;   tl : tstringlist; begin    tl := tstringlist.create;    try     tl.add('country=');     tl.add('class=con');      i:= 0 tl.count - 1  begin       key := tl.names[i];       value := tl.values[key];       assert(value <> #13#10);  // succeeds     end;      max := valuelisteditor1.rowcount;     i:= 1 max  begin       key := valuelisteditor1.keys[i];       value := valuelisteditor1.values[key];       //  value := valuelisteditor1.strings.valuefromindex[i-1];       assert(value <> #13#10);  //fails = 1!     end;        tl.free;   end; end; 

btw, tvle set entirely in object inspector: dragged tvle off palette, clicked strings in oi, clicked in lh cell , typed 'country' (sans quotes), pressed down key , typed 'class' right-arrow , typed 'con'.

obviously, avoid value := trim(value), curious #13#10 coming from.

update: prompted @deltic's answer , helpful comments, decided re-trace steps , added tvle form. following extracts dfm revealing:

  object valuelisteditor1: tvaluelisteditor     left = 16     top = 224     width = 306     height = 135     keyoptions = [keyedit, keyadd]     strings.strings = (       'country='#13#10       'class=con')     taborder = 2   end  [...]    object valuelisteditor2: tvaluelisteditor     left = 440     top = 192     width = 306     height = 246     keyoptions = [keyedit, keyadd]     strings.strings = (       'a='       'b=valueofb')     taborder = 5   end 

so, hindsight, question boils down how did #13#10 dfm? , came me ...

with no previous experience of tvle, when set form, got stuck @ point needed add second row. tried pressing [enter], did nothing, tried ctrl-enter , did nothing either. repeating exercise has confirmed that's how cr/lf got tvle's strings.

so, seems answer q "no, tvle isn't broken, strings property editor has quirk regarding ctrl-enter". in other circs, consider deleting q, seeing it's @ least partly caused operator aberration, perhaps it's better left assist others trip on same point.

update #2 see curiousity has earned me -1. fair enough, i'm still inclined leave q & in place, if illustration of fact problems have deterministic causes, can identified simple things such re-tracing one's steps, particularly knowledgeable looking on one's shoulder, were. perhaps down-voter care enlighten readers future readers such silent -1 is.

you have not shown how value list editor initialised, , suspect problem is. behind tvaluelisteditor nothing more tstringlist (strictly speaking subclass of one, subclass doesn't change fundamental behaviour w.r.t named values).

if apparently empty value in value list yielding value of #13#10 must because actual value has.

this simple test snippet verifies this:

var   i:integer;   k, v:string; begin   ed.insertrow('country', '', true);   ed.insertrow('class', 'con', true);    i:= 1 ed.rowcount - 1   begin     k := ed.keys[i];     v := ed.values[k];     assert(v <> #13#10);  // never fails   end; end; 

where ed tvaluelisteditor on form.

replace first line of code in above snippet however:

  ed.insertrow('country', #13#10, true); 

and assert() fails.

i suggest investigate initialisation of value list editor. guess is being populated reading file using mechanism reading entire line string, including line end sequences, , code adding values each read line not stripping #13#10 line terminators, resulting in values being added <name>=<value>#13#10 in each case.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -