How resize a cxgrid with the mouse? - delphi

I have 4 cxgrid into a cxTabSheet, 3 aligned albottom and 1 aligned alClient...
When the mouse is over the edge of any cxgrid, the cursor mouse doesn´t change to the crSize(NS, WE, NESW, NWSE) and cannot select the border of grid for drag the mouse and resize it.
How can I do this?

The easiest way to do this, without writing any code, is to use one or more splitters on your form: see TSplitter and the Devex custom version, TcxSplitter, in the online help.
To use, place one or more splitters on the form orientated to allow resizing of the grid(s) as you wish, then place the grids on the appropriate areas of the splitters, or on panels on the splitters. One splitter can be placed inside another, so that you can have one resizable area inside another.

Related

Align a component exactly in the middle of a panel

I have a TRichEdit and a TButton on a TPanel, which is not aligned in the centre of the panel:
Is there a quicker way to align these components in the centre of the panel, than just by dragging it around and guessing if it is in the centre?
Also, I am using Delphi 2010.
I tried selecting the components and using the alignment options:
But it only aligned the button to the rich edit:
First, you must not select the panel, because that is not involved in this process.
Second, there is another toolbar Position that has a button to center the selected elements inside its parent.
I have no Delphi 2010 at hand, so I cannot provide a screenshot, but both icons look quite similar.
Quickest way for aligning components at design time is by using right-clicking on specific component and then choosing Position->Align from the shown popup menu.
If you want to align your component to the center of the parent then chose Center in window for either horizontal or vertical alignment whichever you need. If you have multiple components selected Delphi will align the whole group to the center of the parent and not each individual component to the center of the parent.
If you want to align one component to the center position of another other component then select the two components first and then right click on the component on which you want your component to be centered on. And now in popup menu select Position->Align and in the opened window chose Centers wither for horizontal or vertical alignment based on what you need.

Delphi Resizing Form messes up components

I created my form and it looks fine in the standard size when ran with the program, however when I maximize the form, the components get messed up. I anchored the components on the left and right, however a giant gap is created in the middle of the form and I don't know how to fix it. When in the 'Design' view of the program, all my components are touching from me trying to fill the middle gap. I tried aligning, anchoring and searched online for a while with no luck. Any clue?
Form in standard size upon running program:
Form in full screen with giant middle gap:
From the form's OnResize event, you can compute the width and left property values for the component to fit the new size. You can adjust the width of components or distribute the distance between components to get the look you want. Or a combination of the two.
It is also possible to put the components on two lines if the form's width becomes too small. Or use a scroll panel so that the user can scroll to see what is not possible to show correctly given the width.
All that requires coding. Parts can be done using panels and align the panels.

HorizontalSplitPanel - Adjust the splitter position based on component width

Is there a way to add more than 2 components in HorizontalSplit panel without nesting it?
Splitter position should be based on the space allocated for the component. There is nesting of horizontal split panel but the splitter position is not set based on the component visible space
If you want a separate resizable split area for each of those components, then no, you cannot do that with just one split panel and nesting is indeed the solution. If you are fine with just one split, then you can add a layout instead of a component and just keep inserting more components to the layout.
You can use splitPanel.setSplitPosition for adjusting the split position. If your desired split position isn't static and your contents don't have fixed sizes, you could possibly use a tool like SizeReporter add-on for querying the content sizes. Note that this will undeniably cause some flickering, because you need to add the component to the layout before you can measure its size.
A horizontal splitpanel allows one component on the left and one on the right side.
Nothing more
What do you want to achieve?
If you add two layouts to HorizontalSplit there is nothing stopping you in adding more than one component to those layouts. You can also add new SplitLayouts to existing splitlayouts if you want that.

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.

Can TSizeGrip be used to move and resize components at runtime (within FireMonkey)?

FireMonkey's predecessor advertised that it could be used to create CAD and GIS programs. I've been exploring FireMonkey and thinking about how to create a simple CAD program. A basic function is to move shapes around on the screen using the mouse. FireMonkey includes a TSizeGrip component, which I suspect may be applicable to moving shapes and providing nodes at corners and edges of a shape for a user to click on. However, the documentation for TSizeGrip hasn't been completed.
Can TSizeGrip be used to allow end-user movement of FireMonkey shapes? If so, how?
No.
TSizeGrip is provided specifically to act as a "grab handle" for resizing a form, not arbitrary FireMonkey controls or containers.
You can see this quite easily by creating a new FireMonkey HD application. Drop a TPanel on the form and then drop a TSizeGrip onto that panel.
Run the application and you will find that when you mouse over and click on the size grip and drag, the form is resized, not the panel. A size grip control would normally be anchored to the lower right of a form.
If you are wondering why you need a control with such apparently limited use when resizable forms can just be resized using their border, the answer is that it can sometimes be useful to have a form be resizable without having the full draggable border style. e.g. modal dialog boxes.
No - with one exception.
If you create a new component in which you use TPanel and TSizeGrip – TSizeGrip will control TPanel's size, not TForm's size.
If you put TPanel and TSizeGrip on a Form
the TSizeGrip controls the size of the form and NOT the panel
I've just tried it

Resources