Forms don't apply StartPosition property

1 Answer 71 Views
Form
Jana
Top achievements
Rank 2
Iron
Iron
Iron
Jana asked on 20 Sep 2021, 07:50 AM

Hello everyone,

 

I have a little problem with the property StartPosition of a radForm.

When I create a radForm which will be opened with ShowDialog as a modal window at runtime, the start position CenterScreen is not applied. Depending on the size I choose, the modal is sometimes not even fully visible on the screen. How can I resolve this?

I've uploaded a test project which shows the problem:

https://easyupload.io/n58n8v

Thank you in advance and have a nice week!

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 20 Sep 2021, 11:29 AM

Hi Jana,

Based on the test project that you have sent us, I assume that you are experiencing the issue, when running the project on HDPI setting. Can you confirm that, please? You can see the scaling of your system in Settings -> Display -> Scale section. 

If it is different than 100% then you are running on a scaled environment and I would recommend you to develop UI always using 100% DPI. Here is a nice article about that topic.

As it comes to your problem, I will ask you to try to reproduce it, without any scaling (at 100%) and see if it still appears to be broken.

I could not reproduce the issue at 100% on my machine, but I have managed to reproduce it at any kind of DPI scaling.

I have logged the issue on our ticket portal, where you can vote and subscribe for the issue, so you can track its status changes. Here is a link to the item.

I have also updated your Telerik Points.

In the mean time, I can offer you the following workaround of the problem:

    public partial class Popup : Telerik.WinControls.UI.RadForm
    {
        public Popup()
        {
            InitializeComponent();
            Load += Popup_Load;
        }

        private void Popup_Load(object sender, EventArgs e)
        {
            isLoaded = true;
        }

        private bool isLoaded = false;
        private bool isCentered = false;

        protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
        {
            base.ScaleControl(factor, specified);
            if (StartPosition == System.Windows.Forms.FormStartPosition.CenterScreen && isLoaded && !isCentered)
            {
                CenterToScreen();
                isCentered = true;
            }
        }
    }

The main idea is to call CenterToScreen() method, after we scaled the form. the two variables IsLoaded and isCentered are used to guarantee that we call the CenterToScreen() method at the most appropriate time only once - after the form has loaded.

I hope this will solve your problem and if there is anything else that we can help with, do not hesitate to write back.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Jana
Top achievements
Rank 2
Iron
Iron
Iron
commented on 21 Sep 2021, 09:25 AM

Hi Stoyan,

Thank you for your fast reply. I tried to launch Visual Studio with 100 % scaling, but unfortunately, it didn't change the problem.

But I'm not sure if I did it correctly. When I open a winforms project, I see this yellow information and then I simply clicked on "Restart Visual Studio with 100 % scaling". Was that correct?

Stoyan
Telerik team
commented on 21 Sep 2021, 10:52 AM

Hi Jana,

Even if you start Visual Studio with 100% scaling, you'd still be running your project at 125% DPI. 

In order to change the scaling of the entire system, assuming you are using Windows 10, you need to go to Windows Settings -> Display:

There scroll down to Scale:

And here you can set it to 100%.

I assume that the wrong placement will disappear at 100% scaling. If this is the case, you can try the workaround at 125% and see if it works for you.

Kind regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jana
Top achievements
Rank 2
Iron
Iron
Iron
commented on 21 Sep 2021, 03:41 PM

Hi Stoyan,

 

Thank you very much again for your provided information. The popup indeed shows up in the center of the screen when the system display is at 100%.

I've also tried your workaround and it resolves the problem. Thank you very much for your professional and fast support :-)

 

Kind Regards,
Jana

Tags
Form
Asked by
Jana
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stoyan
Telerik team
Share this question
or