#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    40
    Rep Power
    11

    Working with 2 grids


    I have 2 grids, which are in a way linked.

    There can be lots of data in the grids, though they always have the same rowcount.

    What I want my app to do, is when I go down enough rows that the scrollbar starts to move (or the TopLeftChanged event occurs), that BOTH my stringgrids uses the scroll bar so I can see the applicable data in both grids.

    Just changing the selection on the other grids doesn't work.

    This is what I tried
    PHP Code:
      TGridRect Temp = ((TStringGrid *)Sender)->Selection;
      
    Grid1->Selection Temp;
      
    Grid1->SetFocus();
      
    Grid2->Selection Temp;
      
    Grid2->SetFocus();
      ((
    TStringGrid *)Sender)->SetFocus(); 
    this doesn't work, as it is important that both the grids have the same visibility, but not really the same active cell (though not a bad thing).

    Can anyone help me?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    Something like this perhaps?
    Code:
    Grid2->TopRow = Grid1->TopRow;
    The Delphi 6 equivalent of the above works for me, so I think it should work for you too.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    5
    Rep Power
    0
    Just to add on what Scorpions4ever brought foreward;

    Draw1->LeftCol = Draw2->LeftCol

    * if you want to keep the horizontal scrollbars also sychronized.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    40
    Rep Power
    11
    Thanks!!

    Haven't tried it though, but I am sure it'll work. Eventually I opted to display everything on one grid... it's not the same, as the data aren't *that* related, but I just changed the 'visible' property of the old grids to false for now, so it's not hard going back to the old way.

IMN logo majestic logo threadwatch logo seochat tools logo