开发者

c# panel layout problem

开发者 https://www.devze.com 2023-02-13 01:03 出处:网络
I have created a panel in c# application that holds rows of 5 textboxes. Textboxes are added to panel dynamically. It is 500 pixels in width and each textbox is 100 pixels wide.

I have created a panel in c# application that holds rows of 5 textboxes.

Textboxes are added to panel dynamically. It is 500 pixels in width and each textbox is 100 pixels wide.

First textbox is at x-position 0, second at 100, third at 200 and so on.

So the 5 textboxes should fill the panel horizontally. These are shown correctly at my computer but at another computer these textboxes appear as if their width is reduced and they do not e开发者_Go百科xtend to end of the panel. They leave blank space at the end of panel.

Can anyone tell me why is this difference in display of textboxes?


There could be a few different reasons for this. Depending on if you are using WinForms (which I am assuming) or WPF. There is a system DPI that can be changed in windows. Windows Vista and 7 take advantage of this more. The other issue could be with the windows themes (play with the handicap themes). How to check your system DPI


I think that the problem is in displaying textboxes in computers with diferent Windows themes. With Classic windows controls it compute space in different way than when themes are turned on on computer.


Couple things to try, make sure the AutoSize property is set to false on the Panel and the Textboxes. Also, make sure the PreferredSize is also set.


I was having a similar problem, and found this link: C# WinForms messed up control positions? where changing my main form's AutoScaleMode attribute from Font to None or Inherit solved the problem (NB: changing to Dpi did not solve it).

0

精彩评论

暂无评论...
验证码 换一张
取 消