Delphi - How to set vertical scrollbar in TStringGrid, always visible - delphi

I'm using Delphi 2007 for Win32 and need to set the vertical scrollbar in TstringGrid to always be visible. How do you do that?

You can hide scrollbars with the Scrollbar property set to either ssNone, ssHorizontal, ssVertical, even when the number of rows and / or columns would normally make them appear.
You can however not force one or both scrollbars to be always visible but disabled, without creating a new descendent class and overriding methods. Unfortunately the standard grid controls have not evolved much since the days of Delphi 1, so your best bet is using some third party grid control instead. Preferably one that does also show proper proportional scroll thumbs.

There is a scrollbar property that can be set to ssNone, ssHorizontal, ssVertical or ssBoth.

Related

How to fix a column in TStringGrid with delphi FMX?

I want to make a grid with FireMonkey where it has a fixed column, but neither TGrid nor TStringGrid have that property, nor allow me to change it dynamically at runtime, as far as I can see.
Does anyone have a way to make this work?
Imagine I have 500 columns (I don't, and I won't have that number, this is just for demonstration purposes). I want to lock the first column so its content will always be visible as the user scrolls the grid along the X axis (horizontally). Same thing as with the header row, it's always locked in place so when the user scrolls along the Y axis, the header is always visible.
I am using Delphi 10.3.3 CE.

Delphi VCL horizontal container (gallery like) of components (TDBCtrlGrid, TScrollBox)?

I am using Delphi 2009 and I have set (of variable length) of records with the data <image, label, file path> and I would like to present those records in gallery-like structurei with the horizontal scroll of the entire list and, possibly, with no vertical scroll.
TDBCtrlGrid seems to be exact solution (I can keep records in the TClientDataSet and there is lot of automation in place), but is vertical-only collection (at least for Delphi 2009), it has Orientation property but (at least in design time) it controls the scrollbar only (places it in the bottom). So - maybe it is still possible to adapt TDBCtrlGrid for horizontal use?
TScrollBox (with TFrame child elements) is another promising solution, but so far I can achieve that all the frames are stacked vertically and I don't see how can I ask them to be side-be-side horizontally. So - is there way to use TScrollBox for horizonatl, gallery like structure?
I have reserved the option to use TcxDBVerticalGrid, but I am doing everything to avoid it - I am not sure about the capabilities of the complex grid to present images with its own image internal component, I prefer to use TImage or TDBImage component (seems to be robust) inside some container of controles (e.g. on TFrame and put those frames in TScrollBox).
Assuming the question is something like "How can I make TDBCtrlGrid work in horizontal mode?"
In addition to setting the orientation, you should also set RowCount and ColCount to some decent values.

Autosize Form with Memo in Delphi 10.1

I have a problem with a TForm who contain a TMemo. If Autosize is set to True on the TForm, my TForm is halved and then I can size it ...
That's exactly this problem : https://www.youtube.com/watch?v=3eG3kwRgPTo
I'm with Delphi 10.1 Berlin, all is ok with my Delphi XE6.
Did you know how I can fix it ?
Thanks
You have a kind of circular reference in that the child windows are resizing themselves to the parent and the parent resizing itself to the children, and none of them specifying a width. I agree it is odd that adding a TMemo seems to screw things up but like any circular reference it needs to be broken, so either you need to resize the screen programmatically or, as would probably be better in your case, simply size the panels and don't use the align properties of those. I have tried that approach and it works.
Of course this only allows the top or bottom panel to be made invisible - not those in the middle.

(Delphi bug) Controls won't remember their position on form

I have a (Delphi bug?) that is annoying me for months: in one of my apps I have some controls (tedit, tbutton, etc) on a TPanel. Every time I close the project and reopen it I find the controls moved few pixels up. After 20-30 closings the controls are almost out of the panel so I have to drag them back. Anybody encountered such a problem? How to fix it?
I have Delphi XE.
Update:
Actually I have encountered this in two of my projects. Both involve controls on a TPanel.
If I compile the project the controls, in the exe, the controls are at the wrong position also.
I have a TEdit that is aligned to the top (of the TPanel) and its bottom is anchored to the bottom. The bottom will also 'forget' its correct position and move to the top.
Update:
Bug confirmed. It appears when the user changes the Bevel properties of the panel!
This issue is reported in Quality Central #106320 for Delphi XE2, in June 2012.
Its status is still 'need feedback', there is no sample project, but it looks as if has to do with descendant forms.
I suggest that once you have determined the exact location that you want the components to be in, you adjust their position in the FormCreate.
Then, in designmode you can just 'approximately' correct the position quickly, knowing that they will come out right at run-time.
Robs suggestions also sound worth a try.
BTW Should you manage to make a sample project, maybe others can then determine if it is fixed in later versions.
There is evidently some conflict between anchors and position, possibly involving form inheritance. I expect it has something to do with the order that various positioning constraints are applied in, as well as when the parent control's border size or margin gets updated. Besides, aligning to the top and anchoring the bottom sounds like a recipe for problems. Instead, consider clearing the alignment setting and anchoring the top and sides; it should give the same effect. Alternatively, put a spacing control (e.g., a TShape) aligned to the bottom of the panel, and then align the edit control to the client area, which should give the same effect as anchoring to the bottom.
Nonetheless, this should be easy to work around. In your form's OnCreate event handler, move your components to their correct positions by calling SetBounds on them. To stop further movement during the development cycle, you should probably clear the anchors, and then re-set them at run time.
It happened to me also in D7. I found that whenever I have open design time forms and change the resolution of desktop or minimize the IDE the bottom aligned controls are get pushed downwards, sometimes out of the form.
In order to prevent that kind of I use nowadays the same way HTML pages are designed.
Each of my forms have a layout that are divided with tPanels (like or tags used in html) tPanels are aligned according to their design.
Might not be the same problem but I think the solution I've found might work for you too.

Smooth scroll string grid

I need a string grid which can scroll smoothly, as opposed to locking in the top row / left col positions. When you scroll a TStringGrid, the left visible column and top visible row snap into position along the top/left edges. I need the ability for the user to scroll smoothly, not locking these edges into place.
I wouldn't think this is possible to modify in the VCL TStringGrid (or TCustomGrid for that matter) because it relies on properties such as TopRow, LeftCol, VisibleRowCount, etc.. I'm pretty sure I'll need a third party control, but I'd love to use the TStringGrid if possible, because I already have a lot of code wrapped around it. If I do need a third-party grid, then I'm hoping it works closely enough like the TStringGrid.
The short answer is no, you canĀ“t pixel scroll a TStringGrid. You can simulate a grid using a TScrollBox. You can put a grid inside the TScrollBox, make the grid large enough to fit all rows and cols, and turn off its scroll bars, but some things like keyboard navigation will not work.
Other alternative is to use the TVirtualTree in grid mode or TListView. Both have this pixel scroll you want.
I was looking for something similar. Unfortunately, you can't do it with Borland's code but Lazarus can do it
Scrolling the TStringGrid pixel by pixel
You may want to take a look in their code.

Resources