This is the second bug I've found in the latest release of TMS. We are now going to revert back to the previous version until we are confident all issues are resolved.
Problem: The ComboChange event handler no longer gives the new selections in the AItemIndex and ASelection parameters, if the TAdvStringGrid object has the ControlLook.DropDownAlwaysVisible property set to true. It will incorrectly give the values before the change is made.
The following code demonstrates the problem:
1. Drop a TAdvStringGrid on a form.
2. Add CanEditCell handler:
procedure TForm34.AdvStringGrid1CanEditCell(Sender: TObject; ARow,
ACol: Integer; var CanEdit: Boolean);
begin
if( aCol = 1 ) and (aRow > 0) then
CanEdit := true;
end;
ACol: Integer; var CanEdit: Boolean);
begin
if( aCol = 1 ) and (aRow > 0) then
CanEdit := true;
end;
3. Add OnComboChange handler:
procedure TForm34.AdvStringGrid1ComboChange(Sender: TObject; ACol, ARow,
AItemIndex: Integer; ASelection: string);
begin
showMessage( 'Looks like you selected: ' + ASelection );
end;
AItemIndex: Integer; ASelection: string);
begin
showMessage( 'Looks like you selected: ' + ASelection );
end;
4. Add GetEditorType handler:
procedure TForm34.AdvStringGrid1GetEditorType(Sender: TObject; ACol,
ARow: Integer; var AEditor: TEditorType);
begin
if( aCol = 1 ) and (aRow > 0) then
begin
aEditor := edComboList;
AdvStringGrid1.Combobox.Items.Clear;
AdvStringGrid1.Combobox.Items.Text := 'One'#13#10'Two'#13#10'Three';
AdvStringGrid1.Combobox.ItemIndex := AdvStringGrid1.Combobox.Items.IndexOf( AdvStringGrid1.Cells[ ACol, ARow ] );
end;
end;
ARow: Integer; var AEditor: TEditorType);
begin
if( aCol = 1 ) and (aRow > 0) then
begin
aEditor := edComboList;
AdvStringGrid1.Combobox.Items.Clear;
AdvStringGrid1.Combobox.Items.Text := 'One'#13#10'Two'#13#10'Three';
AdvStringGrid1.Combobox.ItemIndex := AdvStringGrid1.Combobox.Items.IndexOf( AdvStringGrid1.Cells[ ACol, ARow ] );
end;
end;
5. Add HasComboBox handler:
procedure TForm34.AdvStringGrid1HasComboBox(Sender: TObject; ACol,
ARow: Integer; var HasComboBox: Boolean);
begin
if( aCol = 1 ) and (aRow > 0) then
HasComboBox := true;
end;
ARow: Integer; var HasComboBox: Boolean);
begin
if( aCol = 1 ) and (aRow > 0) then
HasComboBox := true;
end;
6. Add FormCreate Handler:
procedure TForm34.FormCreate(Sender: TObject);
begin
// Comment out the line below, and the ComboChange event acts as expected
AdvStringGrid1.ControlLook.DropDownAlwaysVisible := true;
AdvStringGrid1.Cells[1, 2] := 'Two';
end;
begin
// Comment out the line below, and the ComboChange event acts as expected
AdvStringGrid1.ControlLook.DropDownAlwaysVisible := true;
AdvStringGrid1.Cells[1, 2] := 'Two';
end;