View Issue Details

IDProjectCategoryView StatusLast Update
0001588JEDI VCL00 JVCL Componentspublic2004-04-22 23:52
ReporteranonymousAssigned Touser72 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001588: Bug FixedCols in TjbDBGrid
DescriptionWhen the FixedCols property has a value and prick in a cell that is not fixed with the mouse, not edit the value of the cell

I am making the proof in a grid with four columns of those which the two first columns are fixed
Additional InformationCuando la propiedad fixedcols tiene un valor y pinchas en una celda que no es fija con el ratón, no deja editar el valor de la celda

Estoy haciendo la prueba en un grid con cuatro columnas de las cuales las dos primeras son fijas
TagsNo tags attached.

Activities

user72

2004-04-07 13:24

  ~0003700

Do you have RowSelect set to true?

user72

2004-04-07 14:44

  ~0003703

I see it here as well when trying to select a row > 1. Can't seem to find the reason, though... Any thoughts?

user72

2004-04-14 04:39

  ~0003837

Last edited: 2004-04-14 04:40

Suggested by Flemming Brandt Clausen (changes in bold):

procedure TJvDBGrid.DoAutoSizeColumns;
var
  TotalWidth, OrigWidth: Integer;
  I: Integer;
  ScaleFactor: double;
  AWidth, AUsedWidth, ALeftCol: Integer;
begin
  if not AutoSizeColumns or FInAutoSize or (Columns.Count = 0) or (FGridState = gsColSizing) then
    Exit;
  FInAutoSize := True;
  ALeftCol := LeftCol;
  try
    // get useable width
    TotalWidth := ClientWidth - (Ord(dgIndicator in Options) * IndicatorWidth) - (Ord(dgColLines in Options) *
      Columns.Count * GridLineWidth);
    OrigWidth := 0;
    // get width currently occupied by columns
if FixedCols = 0 then
      BeginLayout;
    try
      // autosize all columns proportionally
      if AutoSizeColumnIndex = -1 then
      begin
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible then
            Inc(OrigWidth, Columns[I].Width);
        if OrigWidth = 0 then
          OrigWidth := 1;
        // calculate the realtionship between what's available and what's in use
        ScaleFactor := TotalWidth / OrigWidth;
        if ScaleFactor = 1.0 then
          Exit; // no need to continue - resizing won't change anything
        AUsedWidth := 0;
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible then
          begin
            if I = LastVisibleColumn then
              Columns[I].Width := TotalWidth - AUsedWidth
            else
            begin
              AWidth := GetMaxColWidth(GetMinColWidth(round(ScaleFactor * Columns[I].Width)));
              if AWidth < 1 then
                AWidth := 1;
              Columns[I].Width := AWidth;
              Inc(AUsedWidth, AWidth);
            end;
          end;
      end
      // a index of -2 indicates that we want to autosize the last visible column
      else if AutoSizeColumnIndex = -2 then // auto size last visible
      begin
        // reuse AUsedWidth as the actual resize column index
        AUsedWidth := LastVisibleColumn;
        if AUsedWidth < 0 then
          Exit;
        OrigWidth := 0;
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible and (I <> AUsedWidth) then
            Inc(OrigWidth, Columns[I].Width);
        AWidth := GetMaxColWidth(GetMinColWidth(TotalWidth - OrigWidth));
        if AWidth > 0 then
          Columns[AUsedWidth].Width := AWidth;
      end
      // only auto size one column
      else if AutoSizeColumnIndex <= LastVisibleColumn then
      begin
        OrigWidth := 0;
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible and (I <> AutoSizeColumnIndex) then
            Inc(OrigWidth, Columns[I].Width);
        AWidth := GetMaxColWidth(GetMinColWidth(TotalWidth - OrigWidth));
        if AWidth > 0 then
          Columns[AutoSizeColumnIndex].Width := AWidth;
      end;
    finally
if FixedCols = 0 then
        EndLayout;
    end;
  finally
    FInAutoSize := False;
    LeftCol := ALeftCol;
  end;
end;

Does this resolve your issue?

edited on: 04-14-04 04:40

fbc

2004-04-14 05:38

reporter   ~0003846

After thinking a bit, I find this to be a better solution.
I can't see any reason for calling DoAutoSize on mouseup, unless there has been a column resize, and in that case Cell.Y has to be zero.
And doing it this way, will leave BeginLayout/Endlayout active, as it should be, if one have to belive the help-text.

Procedure MouseUp .....
....
....
 inherited MouseUp(Button, Shift, X, Y);
  //Add this line --
  if Cell.Y = 0 then
    DoAutoSizeColumns;
end;

user72

2004-04-14 11:35

  ~0003859

Please try fbc's latest suggestion and let us know how it works for you.

xerkan

2004-04-15 02:55

reporter   ~0003871

The modification done for fbc works but has two side effects:

* When several records are had and you go away to the last column of the last record, the fixed columns put themselves of white color, and the autosize stops working correctly since you make a column bigger can eliminate the last one

user72

2004-04-15 10:01

  ~0003877

I am not sure I understand the problem but I am unable to duplicate it (making the FixedCols draw white, autosize stops working). Have you removed the first fix and do you have the latest JvDBGrid (v 1.45 2004/04/02)?

If yes, could you provide a step by step description to duplicate the problem?

Also, attach the relevant dfm values for the grid.

user72

2004-04-22 23:52

  ~0004024

Since no reply, I assume it works. Post again if that is not the case.

Issue History

Date Modified Username Field Change
2004-04-06 03:10 anonymous New Issue
2004-04-07 13:24 user72 Note Added: 0003700
2004-04-07 13:24 user72 Status new => assigned
2004-04-07 13:24 user72 Assigned To => user72
2004-04-07 14:44 user72 Note Added: 0003703
2004-04-14 04:39 user72 Note Added: 0003837
2004-04-14 04:40 user72 Note Edited: 0003837
2004-04-14 04:41 user72 Status assigned => feedback
2004-04-14 05:38 fbc Note Added: 0003846
2004-04-14 11:35 user72 Note Added: 0003859
2004-04-15 02:55 xerkan Note Added: 0003871
2004-04-15 10:01 user72 Note Added: 0003877
2004-04-22 23:52 user72 Status feedback => resolved
2004-04-22 23:52 user72 Resolution open => fixed
2004-04-22 23:52 user72 Note Added: 0004024