Delphi Resizing Form messes up components - delphi

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.

Related

Move Grid save and cancel buttons from far right, maybe left justify

Is there a way in Vaadin 7 or Vaadin 8 to move the save/cancel buttons to under the last editor column? Or maybe to left justify them? Right now they are right justified under the last column. I would even take left justifying them under this same column. Visually, it is far from the last thing the users edited, so some users get confused. The way I am clarifying it for users right now is by making the Grid as narrow as possible, but it wastes screen real estate.
This will be very difficult in generic case, where column widths can be freely adjusted or their widths are automatically calculated by content. However if you set your columns fixed widths, so that you can make assumptions based on that within your specific application, there is a solution.
Just noting, that the Editor has div, with class name "v-grid-editor-footer", which has the same width as the Grid. So the editor footer does not have logical cells, that would be aligned with Grid's cells. And that is the challenge here. Furthermore the buttons you are refering to are wrapped in a child div of the previous one, with class name "v-grid-editor-buttons"
However you can try to add css rules in your theme in the following way.
.v-grid-editor-buttons {
position: relative;
left: -300px; // Adjust this value experimentally so that it fits your need
}
Below is a screenshot the css applied to Vaadin's Sampler.

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.

How resize a cxgrid with the mouse?

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.

(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