Recent

Author Topic: TKGrid dom't show checkbox status  (Read 508 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
TKGrid dom't show checkbox status
« on: November 19, 2022, 11:27:21 pm »
Hi i made a form using TKGrid but i made some wrong because don't show me at first row status of checbox , but on next rows show me status could be erro when status unchecked but when is cheked  show me on cell...
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.TabSSourcesShow(Sender: TObject);
  2. Var Row,Col:Integer;
  3.     Cell: TMyTextCell;
  4.     RowGrid:Array[0..11] of integer;
  5.  begin
  6.  {$IFNDEF MSWINDOWS}
  7.   KGrid1.DefaultRowHeight := 34;
  8. {$ENDIF}
  9.   KSTGSources.DoubleBuffered := True;
  10. {$IFDEF MSWINDOWS}
  11.   // In Windows Vista and 7 this is much more nicer
  12.   if Win32MajorVersion >= 6 then
  13.     KSTGSources.OptionsEx := KSTGSources.OptionsEx + [gxFixedThemedCells];
  14. {$ENDIF}
  15.      RowGrid[0]:=4;
  16.      RowGrid[1]:=8;
  17.      RowGrid[2]:=11;
  18.      RowGrid[3]:=15;
  19.      RowGrid[4]:=19;
  20.      RowGrid[5]:=23;
  21.      RowGrid[6]:=27;
  22.      RowGrid[7]:=31;
  23.      RowGrid[8]:=35;
  24.      RowGrid[9]:=39;
  25.      RowGrid[10]:=45;
  26.      RowGrid[11]:=47;
  27.   if( DM.SQLQSources.Active = false) then begin
  28.       DM.SQLQSources.ParamByName('ppnid').AsInteger:= BDproduct.FieldByName('pnid').AsInteger;
  29.       DM.SQLQSources.open;
  30.   end else begin
  31.      DM.SQLQSources.close;
  32.      DM.SQLQSources.ParamByName('ppnid').AsInteger:= BDproduct.FieldByName('pnid').AsInteger;
  33.      DM.SQLQSources.open;
  34.   end;
  35. //  KSTGSources.RealizeCellClass;
  36.   KSTGSources.RowCount:= DM.SQLQSources.RecordCount *3 +DM.SQLQSources.RecordCount+3 ;
  37.   KSTGSources.CellClass := TMyTextCell;
  38. //  KSTGSources.PageSetup.Title := 'KGridDemo table';
  39. //  KSTGSources.PageSetup.UnitHeaderSpace := 1; //we want to print a custom header, cm is default
  40. //  KSTGSources.RangeSelectStyle := rsMultiSelect;
  41.  
  42.   KSTGSources.Cells[1, 0] := 'Vendor';
  43.   KSTGSources.Cells[2, 0] := 'Mfr';
  44.   KSTGSources.Cells[4, 0] := 'Cost';
  45.   KSTGSources.Cells[5, 0] := 'Primary';
  46.  
  47.   KSTGSources.Cells[1, 1] := 'Vendor P/N';
  48.   KSTGSources.Cells[2, 1] := 'Mfr P/N';
  49.   KSTGSources.Cells[4, 1] := 'Buy As';
  50.   KSTGSources.Cells[5, 1] := 'Choice';
  51.  
  52.   KSTGSources.Cells[1, 2] := 'Description';
  53.   KSTGSources.CellSpan[2, 2]:=MakeCellSpan(1, 2);
  54.   KSTGSources.Cells[2, 2]:='Lead Time' ;
  55. //  STGSources.CellSpan[3, 2]:=MakeCellSpan(1, 2);
  56. //  STGSources.Cells[3, 2] := 'Lead Time ';
  57.   KSTGSources.CellSpan[3, 2]:=MakeCellSpan(1, 2);
  58.   KSTGSources.Cells[3, 2] := ' RFQ Date ';
  59.   KSTGSources.Cells[4, 2] := 'Atlevel';
  60.   KSTGSources.Cells[5, 2] := 'Multipleof';
  61.  
  62.   KSTGSources.ColWidths[0] := 20;
  63.   KSTGSources.ColWidths[1] := 150;
  64.   KSTGSources.ColWidths[2] := 150;
  65.   KSTGSources.ColWidths[3] := 80;
  66.   KSTGSources.ColWidths[4] := 80;
  67.   KSTGSources.ColWidths[5] := 80;
  68.   Row:=0 ;
  69.   Col:=0 ;
  70. //  while (not DM.SQLQSources.eof ) do begin
  71. //       Row:= RowGrid[DM.SQLQSources.RecNo-1];
  72. //  Cell := TMyTextCell.Create(nil);
  73. //    try
  74. //      Cell.Text := '0';
  75. //      Cell.CheckBoxState := cbUnChecked;
  76. //      KSTGSources.Cell[5, Row] := Cell; // Cell is copied, we must destroy it
  77. //    finally
  78. //      Cell.Free;
  79. //    end;
  80. //    DM.SQLQSources.next;
  81. //  end;
  82.   Row:=4 ;
  83.   Col:=0 ;
  84.   DM.SQLQSources.first;
  85.   while(not DM.SQLQSources.eof) do begin
  86.     KSTGSources.Cells[Col, Row] := Inttostr(DM.SQLQSources.RecNo);
  87.     KSTGSources.Cells[1, Row] := DM.SQLQSources.FieldByName('SuSupplier').AsString;
  88.     KSTGSources.Cells[2, Row] := DM.SQLQSources.FieldByName('lnkMFRid').AsString;
  89.     KSTGSources.Cells[4, Row] := DM.SQLQSources.FieldByName('lnkcurrentcost').AsString;
  90.     Cell := TMyTextCell.Create(nil);
  91.     try
  92.       Cell.Text := DM.SQLQSources.FieldByName('LnkUse').AsString;
  93.       if( DM.SQLQSources.FieldByName('LnkUse').AsInteger =1) then begin
  94.         Cell.CheckBoxState := cbChecked;
  95.       end else begin
  96.         Cell.CheckBoxState := cbUnChecked;
  97.       end;
  98.       KSTGSources.Cell[5, Row] := Cell; // Cell is copied, we must destroy it
  99.     finally
  100.       Cell.Free;
  101.     end;
  102.  
  103.     Inc(Row);
  104.     KSTGSources.Cells[1, Row] := DM.SQLQSources.FieldByName('lnkvendorpn').AsString;
  105.     KSTGSources.Cells[2, Row] := DM.SQLQSources.FieldByName('lnkvendorpn').AsString;
  106.     KSTGSources.Cells[4, Row] := DM.SQLQSources.FieldByName('unuseunits').AsString;
  107.     KSTGSources.Cells[5, Row] := DM.SQLQSources.FieldByName('lnkchoice').AsString;
  108.     Inc(Row);
  109.     KSTGSources.Cells[1, Row] := DM.SQLQSources.FieldByName('lnkvendordesc').AsString;
  110.     KSTGSources.Cells[2, Row] := DM.SQLQSources.FieldByName('lnkleadtime').AsString ;
  111.     KSTGSources.Cells[3, Row] := DM.SQLQSources.FieldByName('lnkrfqdate').AsString ;
  112.     KSTGSources.Cells[4, Row] := DM.SQLQSources.FieldByName('lnkatqty').AsString;
  113.     KSTGSources.Cells[5, Row] := DM.SQLQSources.FieldByName('lnkminincrement').AsString;
  114.     Inc(row);
  115.     Inc(row);
  116.     Col:=0 ;
  117.     DM.SQLQSources.Next;
  118.  end;
  119.  
  120. end;
  121.  
  122.  
you can se image how is show when get fos con cell and how show when lose focus on cell at 4 row col 5...


 

TinyPortal © 2005-2018