View Issue Details

IDProjectCategoryView StatusLast Update
0037284LazarusWidgetsetpublic2020-06-29 16:45
ReporterKolomensky Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
OSWindows 7 
Product Version2.0.8 
Summary0037284: TComboBox: Assigning a value to the Text property can be incorrect before the form is activated
DescriptionTComboBox: Assigning a value to the Text property can be incorrect before the form is activated.
The problem occurs if there is an Item in the Items list for which Upcase (Item) = Upcase (Text), but Item <> Text
Steps To Reproduceput a ComboBox on a Form.
add FormCreate

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.AddItem('abcdE',nil);
  ComboBox1.Text:='ABCDE' ;
end;

run it

Having as Result on form: "abcdE"

alternatively with FormActivate

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.AddItem('abcdE',nil);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  ComboBox1.Text:='ABCDE' ;
end;

Run It and we have as Result on form: "ABCDE"
Additional InformationThis was tested on Lazarus 2.0.2 too.
This problem also applies to TDBComboBox.
TagsNo tags attached.
Fixed in Revision
LazTarget
WidgetsetWin32/Win64
Attached Files

Activities

jamie philbrook

2020-06-29 15:29

reporter   ~0123667

I looked deep into the mess and yes, there is a problem..

Its been there for some time now..

The use of IndexOf of a the STringList is not Case sensitive by default.

 I fixed that by setting that property in the CustomBobox.Create , that fixed the first segment however, there are two locations in code where a search for a matching string is being done.
win32listsl.inc
procedure TWin32ComboBoxStringList.Assign(Source: TPersistent);

This assigns a stringlist from the source to another stringlist for the EDITEXT.

 its apparent the TstringList.CaseSensitive Property isn't getting transferred in the process so it then also uses IndexOf and finds a match of non case sensitive.

 So how to fix? Set the property for the stringlist in both sections or fix the Assign operation of the stringlist ?

Serge Anvarov

2020-06-29 15:51

reporter   ~0123668

As a quick workaround for an application it can be used the HandleNeeded method call at the beginning.

Serge Anvarov

2020-06-29 16:03

reporter   ~0123669

In the TWin32ComboBoxStringList.Assign method, EditText is restored first. Only then is ItemIndex restored, which leads to text replacement.

jamie philbrook

2020-06-29 16:45

reporter   ~0123670

Yes that works to get around that issue but you still have the issue of non case sensitive searches in the
TcustomComboBox.RealSetText.. which sets the itemIndex.

 I suppose doing this kind of by passes this for the moment but after the control is fully initiated and if that function is called again, then what happens ? does it pick a non matching case out of the list ?

Issue History

Date Modified Username Field Change
2020-06-29 11:18 Kolomensky New Issue
2020-06-29 15:29 jamie philbrook Note Added: 0123667
2020-06-29 15:51 Serge Anvarov Note Added: 0123668
2020-06-29 16:03 Serge Anvarov Note Added: 0123669
2020-06-29 16:45 jamie philbrook Note Added: 0123670