Forum > General
How single procedure ends in different results
(1/1)
Marion:
I have a procedure that dynamically adds controls to a TScrollBox with the ChildSizing.ControlsPerLine = 1 so the controls stack from top to bottom. When the ScrollBox starts empty then the child controls are the correct height (See image with empty TEdit). Once a user enters text and saves the dialog, the next time they come back to the form, I repopulate the rows and add the text but now the TEdits are short. When I add a new (empty) row, all of the rows (including the previous ones) stretch to the right height. I'd like to fix this if someone knows what's going on.
Below is the procedure used to add all of the rows to the ScrollBox:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TfrmOptions.DiceTrayRowAdd: TPanel;var pnlRow: TPanel; txtName, txtFormula: TEdit;begin pnlRow := TPanel.Create(boxDiceTray); pnlRow.Parent := boxDiceTray; pnlRow.Tag := FDiceRow; pnlRow.BevelOuter := bvNone; pnlRow.ChildSizing.ControlsPerLine := 2; pnlRow.ChildSizing.EnlargeHorizontal := crsHomogenousChildResize; pnlRow.ChildSizing.Layout := cclLeftToRightThenTopToBottom; //pnlRow.Name := Format('pnlDiceRow%d', [FDiceRow]); pnlrow.Caption := ''; pnlRow.OnEnter := @DiceTrayRowEnter; txtName := TEdit.Create(pnlRow); txtName.Parent := pnlRow; //txtName.Name := Format('txtDTName%d', [FDiceRow]); txtName.Text := ''; txtName.MaxLength := 20; txtName.OnKeyUp := @DiceTrayRowKeyUp; txtFormula := TEdit.Create(pnlRow); txtFormula.Parent := pnlRow; //txtFormula.Name := Format('txtDTFormula%d', [FDiceRow]); txtFormula.Text := ''; txtFormula.MaxLength := 40; txtFormula.OnKeyUp := @DiceTrayRowKeyUp; if txtName.CanFocus then txtName.SetFocus; FDiceRow := FDiceRow+1; result := pnlRow;end;
CharlyTango:
You will certainly have a reason why you choose a solution with a TScrollbos, which is significantly more complex and problematic than other controls.
I would try to solve such “simple” inputs with a TStringgrid, for example
jamie:
AutoSize is set to true maybe?
in any case, I am not sure how the child sizing works but best guess is it may use the FONT height. Maybe you need to set that in the EDIT fields.
Marion:
I finally fixed it. I had to add a Contraints.MinHeight = 40 to each of the TEdits and now it works as expected.
Navigation
[0] Message Index