Jump to content

TopRow and LeftCol of TUniStringGrid


Fujio

Recommended Posts

3 hours ago, Fujio said:

In a TUniStringGrid with a 100x100 cell and a display area of 10x10, how can I display the cell with Row=50 and Col=50 in the upper left corner when I press the button?

Hello,

This is not what you wanted, but a close solution for your case:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  with UniStringGrid1 do
  begin
    Col := 50;
    Row := 50;

    JSInterface.JSCode('Ext.select("#"+'#1'.id+" .x-grid-cell-selected").elements[0].scrollIntoView();')
  end;
end;

 

Link to comment
Share on other sites

Thank you.
I tried it, but the cells with Row=50 and Col=50 are displayed in the upper right corner, not the upper left.
I wrote the following code, and immediately after execution it is 1.png and after pressing the button it is 2.png.

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  UniStringGrid1.Row:=50;
  UniStringGrid1.Col:=50;
  UniStringGrid1.JSInterface.JSCode('Ext.select("#"+'#1'.id+" .x-grid-cell-selected").elements[0].scrollIntoView();')
end;

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  i,j:Integer;
begin
  for i := 0 to 99 do
  begin
    UniStringGrid1.Columns[i].Title.Caption:=IntToStr(i);
    for j := 0 to 99 do
    begin
      UniStringGrid1.Cells[j,i]:=IntToStr(j)+','+IntToStr(i);
    end;
  end;
end;

1.png.4f3c762a302f402eff5e7d81599bd8d6.png2.png.6612a2f4943fbe8a4726b718c9078aa6.png

Link to comment
Share on other sites

Hello,

2 hours ago, Fujio said:

I tried it, but the cells with Row=50 and Col=50 are displayed in the upper right corner, not the upper left.

Yes, I know.

2 hours ago, Fujio said:

I wrote the following code...

So, is it OK for you?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...