|
Hi,
Excuse me if i did not ask my question properly.
i only want to know is it possible to create a class to resize controls belong to a parent while i am resizing my parent (Form or user control)?
because when i am using from anchoring and docking in the controls properties, sizes are will changed but the controls will go under/Over each other.
i do not know what else shall i post!
Thank you for your kindly trying to help me .
|
|
|
|
|
If you're looking to create a class to handle this for you, that's not going to work.
You've simply got more learning to do to properly handle setting up your layouts with TableLayoutPanel, FlowLayoutPanel, Docking, Anchoring, any other containers, ...
It's not a simple "Ask a question and get an answer that will fix everything". The only answer to this problem is more learning and experimentation.
We can't see your layout and screen shots isn't going to help that because we also cannot see the properties of your controls and containers.
|
|
|
|
|
You have to set up an event handler for the form's size changed event, and iterate all of the controls you want to resize.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
HI,
Thank you for your help. do you know an essay through the site?if yes, could you please send its link to me?i have tried to do this but i could not overcom.
|
|
|
|
|
How can anyone possibly do that? You haven't even said what platform you're using. Our answers are only as good as your question .
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
|
Hi,
SOOooooooory, i forgot. i am using c# and windows application.
|
|
|
|
|
Don't - simply design for the smallest acceptable monitor size, use docking, and accept that larger monitors will have a lot of white space. This is the generally accepted solution to different monitor size/resolution.
A control designed for 1280x960 looks bloody silly stretched to 1920x1024.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
1. by using a combination of docked controls, and other controls that are anchored, you can achieve pretty good proportional UI re-sizing in WinForms.
2. you will not achieve good quality arbitrary proportional font re-sizing in WinForms because of changes in font rendering: fonts are rendered clearly in certain fixed "quantum state sizes" ... you want more than that, use WPF, where fonts, like everything else, get run through the vector graphic engine.
I will respond further if you start giving details of your UI structure, and get specific. Describe what AutoSizeMode setting you are using; describe what is docked, and not docked.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Hi,
Thank you for your help and advise.
i am trying to create a class to justify all of the components of the forms and user controls (each one of them, separately). I think it is possible. when i try to use from anchoring or docking, with resizing the form or user control, for instance, textBoxes will go under Buttons (some of them will move). my aim is to justify all controls belongs to a parent while resizing the parent with mouse movement and maximizing.
thanks a million to care about my question.
|
|
|
|
|
Member 13325846 wrote: textBoxes will go under Buttons (some of them will move). Changing the z-order at run-time: you don't want to go there.
While I have a sense of what you want to do, you are not specific enough for me to offer further comment.
You did not respond to the issue I raised about the problems of trying to scale fonts in WinForms.
I suggest you make three visual mock-ups showing the initial UI state, and that initial state sized larger, and smaller. Post links to those pictures here.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
According the the discussion until now and the given answers and comments :
If you want to resize controls when resizing the container-control (Form, Panel, Usercontrol and so on) you have to memorize the location of each control and it's size depending on the Master-Form.
If you now resize the Form each control in it must shrink or grow and each location must be shifted - depending on the changes. For this Anchors and so on are now helpful. You need to create a method which is called with the Form.SizeChanged-Event.
If you do it like this you should know, that not every Control does a properly resizing. Also it will be possible that the look becomes very strange.
|
|
|
|
|
As I read Adam Storr - Playing with C# 7 - Deconstruct, I kept hoping that it would answer at long last the question of how to do with in C#. Alas, it fell short again.
Does anybody besides me wish that C# supported with blocks, or have I overlooked a seriously underused language feature?
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
No. I don't miss basic (in any of it's evil forms) either.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I don't miss Basic, either, but I miss that construct, which came to my attention when it became part of VBA as it manifested in Microsoft Access 2.0.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
Real men don't code in VB, or use any of its bastard constructs, such as with or goto .
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Not even slightly.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Surely, you jest.
with Foo {
.Bar = 123;
.Baz = @"Zap!";
.Goo = 3.14159;
.Ergo = 1.1414141414l4;
}
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
Nope, don't miss it at all.
With Intellisense, it's really not needed (and Intellicode is even better at it) - I'd rather be able to see what I'm dealing with than hunt back through code to find out what I'm affecting (and if I move or copy code that could lead to trouble).
Why would you think you need it? It's bad enough that the terminally lazy use var for everything making maintenance hard enough - do we really need other VB "they can't handle the truth" constructs as well?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I agree that I can do without most of it. However, as I've adapted it (see illustration), it seems to me that it is very much in harmony with the spirit of C#, which favors brevity whenever it makes sense.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
Speaking of hunting back through the code, C# 7 gives us this little gem:
if (int.TryParse(input, out int result))
Console.WriteLine(result);
else
Console.WriteLine("Could not parse input");
You get to declare variables in the call to TryParse, or any other method that takes out parameters.
I no likey. I would class this as one of C#'s little "you can't handle the truth" constructs. The docs says it makes the code easier to read. I respectfully disagree.
|
|
|
|
|
Dave Kreskowiak wrote: I respectfully disagree.
Well, of course you would. It should obviously be:
if (int.TryParse(input, out var result)) ...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I can see what they are trying to do - scope the variable to just the code where the result is actually valid:
{
int result;
if (int.TryParse(input, out result))
Console.WriteLine(result);
else
Console.WriteLine("Could not parse input");
} Only it's out of scope in the else block.
And that does make some good sense.
But it is ugly - I'll get used to it and it should improve reliability in the long term.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|