TDBAdvGrid.GetColumnByFieldName returns wrong it

Hello,


we have recently updated the component TDBAdvGrid to version 2.4.2.5. After this update some of our applications begin to throw exceptions when using ColumnByFieldName property. After analysing the error we discovered that the property has changed and is not working fine.

We commented the GroupColumn section, because we think it's not necessary:


function TDBAdvGrid.GetColumnByFieldName(AValue: string): TDBGridColumnItem;
var
  i: Integer; //,idx 
begin
  Result := nil;
  i := 0;
  //idx := 0;


  while i < Columns.Count do
  begin
    if (StrIComp(PChar(Columns.Items.FieldName), PChar(AValue)) = 0) then
    begin
      Result := Columns.Items;
      //idx := i;
      Break;
    end;
    inc(i);
  end;


  {if (GroupColumn <> -1) then
  begin
    if (idx >= GroupColumn) and (idx > 0) then
      Result := Columns.Items[idx - 1];
  end;}
end;


We group by a column, but once the while has found the right column matching with the FieldName there's no need to decrease the index.

In this demo app, it is shown that this code is necessary & correct to determine the column for a field with & without grouping

http://www.tmssoftware.net/public/GroupColumnByFieldName.zip 

It is unclear in what circumstances you experience an issue with ColumnByFieldName[], so if a problem persists, I'd suggest to contact us by direct email with a sample source project that demonstrates the issue.

In the same example add Button3:



procedure TForm1.Button3Click(Sender: TObject);
begin
   ShowMessage('The car has : ' + DBAdvGrid1.ColumnByFieldName['CC'].Rows[DBAdvGrid1.Row]);
end;


The behaviour is different when grouped. It does not show de CC field when grouped.

We've investigated this and this indeed appears a side effect of the fix we applied to get the proper column index. This side effect has now been addressed. The next update will address this.

Great!! We'll update as soon as you publish it.