June 30th, 2007, 11:38 PM
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!
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.
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.
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.
Originally Posted by steve6341
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- 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.
March 14th, 2013, 05:29 AM
Great fix thanks this helped me too.
ParamVDBGridWithTextValue.Width := ParamVDBGridWithTextValue.Width + 1; // Show Vertical Scroll bar
ParamVDBGridWithTextValue.Width := ParamVDBGridWithTextValue.Width + 1;
September 3rd, 2013, 12:34 PM
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.