[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 876
  • Last Modified:

Move To StringGrid Component

Hello,
my name is Angel, and I'm from Barcelona,Spain. I'm sorry but my Englishis not to good that I wish.
I'm working with Delphi 2 in a project. The problem I've is working with StringGrid component.
For example, when the StringGrid shows on the screen, appears 20 elements and a horizontal scroll bar. There are 100 columns and one row. I would like that someone could help me and said me how I can move or go inmediately
to one specified columns in the grid (for example when I press a button I would like that inmediately the grid move to this position and this colums was displayed and marked in the Grid, only one position). At the moment, I'm not found anything propertis or methods to do this.

A lot of thanks for your time.

My e-mail is sa328@blues.uab.es
0
Anglaf
Asked:
Anglaf
  • 2
1 Solution
 
erajojCommented:
¡Hola!
It's in the help. You just have to find it.
If you want to show, for instance, column 50 then just do
like this:
    .
    .
  with MyGrid do begin
    Col     := 50;
    LeftRow := Col-(VisibleColCount div 2);
  end;
    .
    .

Almost the same goes for rows:
    .
    .
  with MyGrid do begin
    Row    := 50;
    TopRow := Row-(VisibleRowCount div 2);
  end;
    .
    .

This will show the selected row/col in the middle of the
TStringGrid. You can, ofcourse, combine the two.

Hope this helps!

/// John

0
 
erajojCommented:
Sorry!
A typing error in the answer will render it useless.
It should be like this:
    .
    .
with MyGrid do begin
  Col     := 50;
  LeftCol := Col-(VisibleColCount div 2); // < LeftCol fix
end;

Excuse any inconvenience!

// John

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now