c# - Using anchor property with dynamically added controls -
I'm adding some text boxes dynamically in sequence. Everything works well that means the text boxes combine the anchor, and automatically until the form is maximized. After maximizing the form, the text boxes are added to the same place, while the form No was maximized, it causes the text box to be incorrectly encoded.
How can I ensure that all the text boxes are in the same place and of the same size whereas the windowstate is normal and is also the maximum?
Edit:
Edit BTW I am using C #
Edit:
Will a FloleLippage be useful?
This is a very old question, but maybe I am capable of answering it.
After reading all your comments, I think that can summarize your problem:
- You have a form on a specific size and a runtime But by adding some control to a specific location, set the
to the top with anchor. Correct. - If you just display the form and reveal the controls, then everything works fine
- If you maximize your form (or resize its size) ) Then you win your control
You can try some different ways to get rid of this problem:
- Use, Take For Care and maybe already create all your necessary controls and just toggle the visual state Please.
- Use the right value for the location of your newly created controls.
The other thing is that you have an error (I think). If your form has the original size, you did not find anything to calculate the location of your control. If the size of the form has changed (for example max) you have to consider several factors, then to get the correct position.
- Delta value in your current size from your default size.
- Anchor you want to set in your control.
In your case, you want to control which anchor is top | Correct , but the location is at the top left . In that case you have to calculate the difference between control.location.x and the default size in the form.width. Then you take this difference and want to reduce it to the current width. You can now have control over this situation (changing the top shape never changes) If you have below. But there is an anchor right you control. Control. A and compute along with form.height.
Behavior and calculation if there is no anchor, then top | Bottom or left | The correct is left as a drill for the set reader. ; -)
- If you want to keep a new control, you can change somewhere
form.- > Add the control you want
- Restore previously saved values
- Forms should be visible again.
Comments
Post a Comment