I build a usercontrol in our develop environment, and it looked exactly as I wanted it to look.
In our test and acceptation environment it looks exactly the same.
But, when we released it to our production environment the buttons at the bottom of the screen moved up a bit and are now slightly over a textbox.
How can I make my usercontrol so that it looks the way I want to in every environment? And what made this error possible? I believe we use the same version of Windows.
As we couldn't find a solution, we decided to check our architecture of the form and found some ambiguities. I had made a mess of the stack panels and solved it with lots of white space. After making a proper form the problem didn't occur anymore.
Related
I have been developing winform applications for a long time and I've never noticed something very simple, almost basic so I went back to the basics, I made a big form with a button on the extreme and I noticed that the size of the form changes completely when run:
design
run
As you can see the form size gets smaller and the button is hidden.
The properties are the default ones AutoSize false and AutoScaleMode Font.
This question is similar to this but unfortunately the answer there is not useful since the recommendation is the default.
Note: This is automatically solved when my notebook gets connected to another display
Below are some steps you can try if one of them can solve your issue:
If the problem occurs only when you connecting with other monitor, try to change the settings when connecting, does this happens to other PCs too? Or try to use another PC or install a VM (Virtual Machine) to run it there.
Check your DPI settings, for example in Windows 7, is that Smaller - 100% (default), or Medium - 125%, or Larger - 150%?
Try to set Form's property AutoScaleMode to Dpi or Font for each case.
If the problem still persists, try to create the sample form with the help from Creating a DPI-Aware Application.
I once tried to use FlowLayoutPanel control to arrange some identical elements such as buttons, pictureboxes. If possible, try to use it when applicable.
Last one, try WPF instead, it seems complicated at first, but you will get used to it soon and find out interesting things that Winforms doesn't have. You can arrange control to a grid (similar to a table), then put your controls to each cell with no problem. My suggestion if you plan to learn from ABC: WPF Tutorial.
Leave comment if you need more help, I will come back to see if any further I can provide. Because I've come into this obstacle when creating an app before :)
Set button "Anchor" (Right*, bottom) in property window
I am having a rather odd issue that I have been unable to find the answer to. I have 2 PCs that I am doing coding on - one a desktop PC and one a notebook (QuadHD resolution). Each has Windows 8.1 & Visual Studio 2013 Update 5 installed.
I have localized all my Forms and it seems that when I edit the Winform on my notebook, it causes very odd resizing issues to occur. For example, if I simply change the "Language" property from one language to another (that I have already translated), the entire form is skewed and re-sized, completely destroying all the layout of the form in the selected language. On another form, the "ImageScaling" property is erroneously changed from 16x16 to 40x40.
The issue seems to be related to the changing of the 'Language' property. Almost like there's some sort of resizing logic & layout logic being applied when this property is changed.
When I perform the same operation on my desktop PC, I get no such odd modifications (as I'd expect). This obviously renders my notebook completely useless for being able to do any WinForms work!
I initially thought this might be related to some quirk with the QuadHD display (i.e. 3.2k x 1.8k). I have tried to reduce the screen resolution to a regular HD quality, however this doesn't seem to resolve the issue.
Does anyone have any hints about what I could try to fix this problem?
Thanks.
The only workaround I have been able to come across so far is to ensure that your Windows Settings->Display->Scaling is 100% BEFORE making any modifications to the form (including changing any seemingly innocuous properties such as 'Language').
On high-resolution screens, this unfortunately makes the content almost unreadable but at least the forms are not completely ruined/resized when you edit them.
You will unfortunately need to do all your edits in this mode and commit them before reverting your scaling back to its original setting.
I have written several WinForms apps in my life, and every once in awhile something will go wrong with the layout at run-time. Today, while I was fiddling with the fonts in my application (mainly whether fonts were bold or not), I found that a control (which was anchored to all four sides of a TabPage) was extra-wide at runtime, going beyond the right edge of the page. I fiddled with the fonts again and the problem disappeared. Then I tried to replicate what I thought caused the problem in the first place, but it did not recur.
Another problem I sometimes have is that a Form with no MaximizeBox will randomly start maximized--maybe not on a development machine, but on a user's machine.
Can anyone tell me if they've had one of these problems and found the cause or solution?
Make sure you are familiar with the Anchor and WindowState properties, and set them to the correct values.
I'm starting my first C# project, and I want to make a "form designer" (like the one in VS).
The idea is, there will be a visual form designer with a limited toolbox, which will generate Python code (later more) to create the same form.
Problem is, I have no idea how to even get started. First of all, I have the form designer in VS: how do I make a "form-within-a-form?"
Next... I have no idea how complicated this is going to be. I suppose I could just make little boxes appear beside each control created on the form when it is clicked, for resizing, and make a textbox appear on it when double clicked or something, to change the text in it... Things like this.
So another thing I would like to know is this:
I do have programming experience in C and C++, I've done PHP for a number of years and am starting with Python as of recently. I've generated forms dynamically in VB6. Given this experience, am I in way over my head with this project?
this looks like a really good place to start. It has a pretty good example to get you started. You can even download his source (registration required).
It sounds like you're aware it's non-trivial for a C# first-timer. If you keep it pretty simple, it sounds like you're heading in the right direction (although a web-based form designer might be easier).
SharpDevelop would be an example of a full-featured IDE that can be re-purposed, but that's way over the top.
Good luck!
For most people starting out in C#, this project would be too much. With your VB6 background, you may be able to pull it off, though.
Here's a hint: the Visual Studio Windows Forms designer draws controls on its surface - by asking the controls to draw themselves.
I hope I am able to illustrate the problem using a lot of images. First of all, I was no real fan of XAML (Silverlight issues, crashes in Preview, and so on...)
Now, with VS2010 the situation has become better. There are still a lot of things I like better in code, but I also want a preview in my VS.
So, take a look at the following control: It is really simple, a todo details list. The first screenshot shows the code of the control, pretty straighforward:
CodebasedControl http://img28.imageshack.us/img28/2263/invoicea49.png
There is no XAML, so obviously no preview. Of course, I could encapsulate it in another control, like shown in the next screenshot:
CodebasedControl http://img11.imageshack.us/img11/9515/invoicea48.png
But, in that case I have an additional file I do not want or need.
So I had the idea to move the init stuff inside the contructor of a XAML control. For simplicity, I used simple elements. But they do not show up in the preview...
CodebasedControl http://img99.imageshack.us/img99/5547/invoicea47.png
CodebasedControl http://img512.imageshack.us/img512/9625/invoicea46.png
Finally, I know I could use the controls in other parts of my app when creating UIs. But I am using layout manager, PRISM and a lot of other stuff, so I just want an easy preview of some specific control I created (without having to have a XAML wrapper file for each control)
Thanks for help, and sorry for the post structure, but I though with images it is better to understand...
Chris
Ok,
I found a way. Basically I am tricking VS by changing the XAML, but keeping the code-behind linked to the file. It the same like the wrapper solution, but without having a dedicated extra class or file. I am using the "xaml-infront" file for preview.
This solution only works with pure code controls, I have to do more research for mixed controls (at least I think so.. but it is enough for me for now).
Please be aware, the code behind is NOT partial anymore. It could be placed anywhere else, what I am doing here is basically only related to file-names and visual studio "readability"..
See screenshots for explanation:
alt text http://img15.imageshack.us/img15/5456/invoicea50.png
Some space for easier reading
alt text http://img186.imageshack.us/img186/1545/invoicea51.png