0
votes

In my solution, I have a project in which I'm creating custom controls. When I build that project, I can insert the custom control in another project through the designer. All works well

With one of those controls however, and one of the forms, I'm having trouble. It's supposed to be a control of fixed size, with a listbox, a button, a groupbox and little else. But when I drag it from the designer, into this particular form, the listbox and button sizes are all wrong, way bigger than the original. This doesn't happen with other controls nor with other form. The properties I see in the properties window for all the forms (except for Text, Font, Name...) are the same.

I'd appreciate your ideas and guidance as to how to look for what's going on. I'm quite new with VS and .NET

Thanks

1
Check the AutoScale mode properties. (It will be "Inherit" by default, so check the parent's -- e.g. Forms -- properties as well. Try changing this value to see if the issue is fixed.) - user166390
@pst, this was definately the issue. AutoScale was set in all forms to Font, but the text font size of that particular form was about double than the rest. When I reduced it, all the other controls shrank but if I fix all of them, it should all work - Rojo

1 Answers

1
votes

This will happen when that control was designed on a machine that had a different video adapter DPI (dots per inch) setting. When you use it on yours, the control automatically rescales itself to accommodate your machine's DPI setting. So that it appears just as large as it did on the original machine. In inches, not pixels.

This is normally highly desired, you don't want to mess with the control's AutoScaleMode property. Because if you do, it will misbehave on the user's machine when it has a different DPI setting. Fix your problem by editing the control's Designer.cs file. Look for code at the bottom of the InitializeComponent() method that assigns the AutoScaleDimensions property and make it the same as a control created on your machine. You may then also need to tweak font sizes.