Solved

Move To StringGrid Component

Posted on 1997-05-25
2
846 Views
Last Modified: 2008-03-17
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
Comment
Question by:Anglaf
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
ID: 1336578
¡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
 
LVL 4

Expert Comment

by:erajoj
ID: 1336579
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now