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

    Join Date
    Oct 2004
    Posts
    61
    Rep Power
    12

    DBGrid and disappearing scrollbar


    This is a stupid question which I'm almost positive has a simple answer, but I can't figure it out. I am using 3 DBGrid components with corresponding datasource components tied to KADaoTable components. The 3 tables are joined together MasterSource/MasterFields. (They display artist, album, track information) You can click an artist, which filters the list of albums to show only those by that artist, then click an album and see the tracks in the third grid on that album. Simple stuff. The problem is sometimes (and I can't find the pattern) the vertical scroll bar on the right side of the DBGrid component is not displayed on the album and/or the track grid. You can press the down arrow key and scroll to the additional albums or tracks. Or, you can randomly click around to different albums/artists and the scroll bars will magically come back. Not 100% sure but I think is related to the KADao components. Any help would be great. Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    I have no experience of KADaoTable.

    My guess is it has to do with how many rows the DBGrid thinks are in the result set.
    If it assumes only, or less than, the available rows in the grid it will hide the scrollbar.
    Once you scroll down I presume more rows are fetched and the result set count gets larger.

    See if KADaoTable lets you set the number or rows retrieved or something along those lines.

    Clive
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    61
    Rep Power
    12
    A couple of things I have found...

    I am able to get the number of records in the result set. I find it with KADaoTable->RecordCount. Unfortunately, the number it reports is always correct, although the scroll bar is not always present. I don't know what this means. The DBGrid component seems to display the scroll bar when the result set contains any more than one record. Even though I have more than enough room for 10+ records, the scroll bar shows if the result set contains only 2 records. It also seems as though the scroll bar disappears on the next record set following a result set of one. In other words- If you select an artist that has only one album, the DBGrib for albums will not display a scroll bar (This is OK). If the next artist has 15 albums, the scroll bar will not come back (Not what I want). (This seems trivial since most artists do not have 15 albums but I am having the same problem listing tracks on an album- the scroll bar is sometimes absent and you can't really tell if there are more tracks on an album without pressing down arrow) If you click another artist with only one album, then another artist with multiple albums, the scroll bar will come back until you hit another single-album artist. I have tried several procedures on DBGrid like DBGrid->Refresh() and DBGrid->Update(). They do not help.

    I hope this indicates something to someone out there. I would really like to get this working.

    Thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    Which version of Delphi?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    61
    Rep Power
    12
    Its C++ Builder 6.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    61
    Rep Power
    12
    More info...

    It works fine on Windows 2000 machines. The problem is only on Windows XP.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    Originally Posted by steve6341
    More info...

    It works fine on Windows 2000 machines. The problem is only on Windows XP.
    I have seen some comments elsewhere to the same effect and that it is a problem with Delphi6 (at least) and XP.

    One suggestion I saw (slightly modified by me).

    In the AfterScroll event of the parent Dataset add these two lines.

    ChildDBGrid.Width := ChildDBGrid.Width +1;
    ChildDBGrid.Width := ChildDBGrid.Width - 1;

    I have no idea if it will work.

    Clive.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    61
    Rep Power
    12
    Clive- That is great!
    That works as a great workaround. This will fix a similar problem I have in 2 other apps. I can't thank you enough. I really appeciate you repeatedly following up with this thread. Thanks.

    Steve
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0
    Great fix thanks this helped me too.


    ParamVDBGridWithTextValue.Width := ParamVDBGridWithTextValue.Width + 1; // Show Vertical Scroll bar
    ParamVDBGridWithTextValue.Width := ParamVDBGridWithTextValue.Width + 1;
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Smile Disappearing Scroll bar moving offview-Great Fix


    This solution still works 6 years later for XE4 on Windows 7.
    The scroll bar moves out of sight when you send a filter through the data on the grid and it reloads. Apparently all you need to do is remind it of what the width was set to originally.

    You would think the designers would fix this.

IMN logo majestic logo threadwatch logo seochat tools logo