10-05-2019, 04:55 PM
Hi
I have a TIWGrid Control with 6 columns and 10 rows.
For all cells in grid I create a TIWEdit Control. (button Fill)
procedure TIWMainForm.IWButton1Click(Sender: TObject);
var
i, j: Integer;
begin
for j := 0 to IWGrid1.RowCount - 1 do
for i := 0 to IWGrid1.ColumnCount - 1 do
begin
with IWGrid1.Cell[j, i] do
begin
Alignment := taCenter;
Width := IntToStr(Round(IWGrid1.Width / IWGrid1.ColumnCount));
Control := TMyIWEdit.Create(IWGrid1);
with TMyIWEdit(Control) do
begin
X := i;
Y := j;
Text := '';
Width := StrToInt(IWGrid1.Cell[j, i].Width) - 10;
OnAsyncKeyDown := OnAsyncKeyDownControl;
OnAsyncClick := OnAsyncClickControl;
end;
end;
end;
SetFocus(0, 0);
end;
Any IWEdit control has attached procedure for OnAsyncKeyDown event (code below).
The procedure realize the below behavior:
When enter to first control in any rows, enter any value to IWEdit control in selected cell and push enter key
all other IWEdit controls in current row will have the same value.
And here is a problem.
All IWEdit controls in current row, wchich have changed value, are move to left, upper corner of IWGrid control.
In Intraweb ver. 14.2.6 i haven't the problem..
In Intraweb ver. 15.1.6 problem exists.
Where can be a problem?
Test project:
https://github.com/PeterDelphinsky/IWGridTest
procedure TIWMainForm.OnAsyncKeyDownControl(Sender: TObject;
EventParams: TStringList);
var
pKey: Integer;
pText: String;
i: Integer;
begin
if not TryStrToInt(EventParams.Values['Which'],pKey) then
pKey := 0;
if pKey = 13 then
begin
pText := IWGrid1.Cell[Y, X].Control.Text;
if (X = 0) and (pText <> '') then
begin
for i := X + 1 to IWGrid1.ColumnCount - 1 do
IWGrid1.Cell[Y, i].Control.Text := pText; //<--
Exit;
end;
// (...)
end;
end;
I have a TIWGrid Control with 6 columns and 10 rows.
For all cells in grid I create a TIWEdit Control. (button Fill)
procedure TIWMainForm.IWButton1Click(Sender: TObject);
var
i, j: Integer;
begin
for j := 0 to IWGrid1.RowCount - 1 do
for i := 0 to IWGrid1.ColumnCount - 1 do
begin
with IWGrid1.Cell[j, i] do
begin
Alignment := taCenter;
Width := IntToStr(Round(IWGrid1.Width / IWGrid1.ColumnCount));
Control := TMyIWEdit.Create(IWGrid1);
with TMyIWEdit(Control) do
begin
X := i;
Y := j;
Text := '';
Width := StrToInt(IWGrid1.Cell[j, i].Width) - 10;
OnAsyncKeyDown := OnAsyncKeyDownControl;
OnAsyncClick := OnAsyncClickControl;
end;
end;
end;
SetFocus(0, 0);
end;
Any IWEdit control has attached procedure for OnAsyncKeyDown event (code below).
The procedure realize the below behavior:
When enter to first control in any rows, enter any value to IWEdit control in selected cell and push enter key
all other IWEdit controls in current row will have the same value.
And here is a problem.
All IWEdit controls in current row, wchich have changed value, are move to left, upper corner of IWGrid control.
In Intraweb ver. 14.2.6 i haven't the problem..
In Intraweb ver. 15.1.6 problem exists.
Where can be a problem?
Test project:
https://github.com/PeterDelphinsky/IWGridTest
procedure TIWMainForm.OnAsyncKeyDownControl(Sender: TObject;
EventParams: TStringList);
var
pKey: Integer;
pText: String;
i: Integer;
begin
if not TryStrToInt(EventParams.Values['Which'],pKey) then
pKey := 0;
if pKey = 13 then
begin
pText := IWGrid1.Cell[Y, X].Control.Text;
if (X = 0) and (pText <> '') then
begin
for i := X + 1 to IWGrid1.ColumnCount - 1 do
IWGrid1.Cell[Y, i].Control.Text := pText; //<--
Exit;
end;
// (...)
end;
end;