I have a scrollable panel in which I have a lot of controls. Everything is fine, the design looks great, but the problem is when I press compile every control in panel change their main position which result a big blank space in the panel and looks totally ugly.
And not only that, after I close the compiled application, the controls inside panel from Visual Studio designer are changed in the same way as the compiled app so I have to change their position manually again.
What should I do to fix this?
Okay. I fixed my problem by adding that scrollable panel to another panel and setting dock property to fill over that panel. Everything works fine!
I don't know what type of app you use but most of them have a locked property.
https://msdn.microsoft.com/en-us/library/80xxxf69(v=vs.110).aspx
maybe this is what you are looking for, if you give some more info the type of form you use etc i can have a closer look into it.
Related
I have fields in a document that are displayed as UserControls in a WPF Window (inside tabs).
I needed to make an autosearching feature that displays results below the field.
I went with a adorner containing controls inside (a list).
The first problem is that I could not access the adorner layer for a control inside a UserControl.
I went with finding the AdornerLayer of the Window. Unfortunately if I put the adorner inside it I would not see it anywhere.
The next attempt was to put an AdornerDecorator inside the UserControl.
This worked fine if I was drawing the adorner above the control:
However if I was to put the adorner under the text field the controls below would be drawn above the Adorner:
Is there a way to make this second "below" case work properly?
Have you tried using a Popup already? Popup is also what the ComboBox uses afaik, so i think thats pretty much what you are looking for.
I guess you will not get the decorator to work as long as you add the below items after the textbox, so the will always have a higher zindex. Maybe setting Panel.ZIndex property works, but i think thats a pretty dirty solution.
I've tried looking many places for an answer to an issue I'm having and so far I've found nothing.
What I currently have is a c# windows form with user controls inside it. Some user controls have other controls inside them. What happens when I change the text in a textbox, is its parent windows will no longer resize like they should when changing the window size. i.e. A horizontal scrollbar will appear even though horizontal scrollbars are disabled in that specific window. Its almost as if changing the text changes the parent window's styling.
In case this is too vague, I have a textbox inside a panel with a docking property set to fill. The panel has a padding of 10 in order to allow the textbox to have some white space for aesthetic purposes. This control resides within a parent control (we'll call it parent 1), which in turn resides within another control as well (we'll call it parent 2). So when I change the textbox's text (at all, even adding a space), will then make parent 2 have a horizontal scrollbar flicker and sometimes even remain when resizing the form window manually.
You should make sure that not only the TextBox in the UserControl is docked to fill but also that the user control itself and its parent (and its parent) are Docked correctly or have anchor set so that they resize with the Form.
Do you execute any special code when the user enters a character? (KeyPressed event etc.). If yes you should try disabling the events temporarily to see if they cause the problem.
If you post a sample of your code it would be easier to help. Without this we can only guess, like I tried...
I found out my issue! When using autoScrollBars and double buffering, it caused the horizontal scrollbar to show when it shouldn't have (at least in my case) when resizing the window. The answer was simple, forget the autoScrollBars, and implement my own vertical scroll bar!
I was actually getting some code to post up on here for you guys to look at, but when looking at it, I decided to forget the autoscroll, and lo and behold it worked!
I'm actually curious as to why that is though. My friend heard that .net has some issues with autoScroll but I didn't think it would be to this degree.
My application has several controls. Like in one screen has TreeView on left side, GridView with paging in the middle and 4 buttons at right side. The controls properly appear when the form is in a maximized state, but if I minimize it the controls do not properly fit on the screen.
I tried with different different tricks like table layout.. in dat I added a panel, etc...
But I could not solve the problem.
How can I create such type of screens which fits independently of size of my window?
Thanks
I had the same problem a while ago. In my case i had a Button and a ListView within a GroupBox that was inside a SplitContainer, which was within a UserControl on a TabControl. I wanted the button on the top right located and anchored and the ListView took the space leftover, so i couldn't dock it. Instead it was anchored in all four places.
In my case my button and the listview are worked and behaved correctly in the designer, but in my running app the button was positioned to far on the right and the ListView size had also a too much width.
For a first bugfix i did some iterations about positioning the button in the designer a little more to the left, check it running mode, re-align the button in designer from the impression i had in the last run.
So i got it to work and started over with some other thing i had to do in my app. After a while i got a new feature request and needed another button within this messy thing. This time i did a complete rebuild of the gui elements on a new usercontrol, just to see if the problem reappears. To my amazement this gui mock just behaved as expected.
Within my code i didn't anything about changing the location, size, anchors, docks, etc. So the problem had to be within the InitializeComponents() code created by the designer.
I started with a diff of both versions and couldn't see any big differences (there were a lot of them, but only minors like size, location or name). So i started to put code from my crazy usercontrol into the mock and running the mock in my app. After several copies the problem also appears in my mock, so i got the root cause of the problem.
What do you think, which property leaded to the crazy behaviour?
It was the MinimumSize of my SplitContainer!
So to get really the root cause of your problem you should start over with an empty UserControl (or Form) and just place all the elements on it with the desired behaviour (size, location, anchor, dock).
Nothing more!
Then test if this mock behaves the way you want and if not, post this code here and tell us what you expected to see.
I have a tabcontrol on my form, on each tab I have a control, each of these controls are similar i.e. they each have a table and a couple buttons and each control is set to Dock Fill
When I view them contols in design view something weird is happening, the first tab that is viewable has it controls placed as you would expect and all is fine, but the second and third tab each the controls appear off centre, overlapping the edges of the tab.
I have experimented with placing different controls on different tabs and it appears that if a control is on the first tab it appears fine, if it is on any other it sometimes appears weird.
The really big problem is that this seems to be appearing at run-time as well, but only sometimes.
I've checked the properties of the controls and the tabs but all seems to be the same.
Any advice would be much appreciated.
Kind regards
MeeM
Seems like a bug to me, make sure you have all the latest updates for Visual Studio.
Is this a UserControl that you are placing on a tab? If so, I would check all the layout properties on the user control and the child controls inside the user control. I have had this problem before, but I can't remember off had what I did to fix it.
Try this:
First thing is to verify the z-order of your controls is correct. For that open your Document Outline window (View->Other Windows->Document Outline) and visually check for the order of each control one by one. When setting the docking properties of controls the z-order of the controls is applied in reverse; that is: the first child control shown in the document outline has docking precedence over those at the same level lower in the document outline window.
Verify that no 2 child controls of the same parent (in your case the tabControl) have the DockStyle.Fill. As a good practice with docking, only one of the child controls should have its docking set to Fill. If you have this case it is most likely rethinking your layout flow will allow you to change it and have only one with Fill. The other docking styles (right, left, top, bottom) can be used in more than one child control and they'll never cause any problems. Only Fill is the problematic one.
If 1 nor 2 solved your problem, my advice if to avoid docking altogether and use Anchoring instead. You can essentially get very similar results using the Anchor property of the controls. I actually like this approach more, since is kinda similar to WPF anchoring.
If 1, 2 not 3 solve your problem. Post an image with your document outline and I'll recreate it here, fix it and post the solution here.
Hope it helped!
I assume that these are user controls we are talking about. Have you changed the layout of the control (class) itself since you added the user controls into your tabs? If so, they will not automatically update with the new value (for Dock, width, height, etc.).
EDIT > SOLVED: It turns out that I had set all of the UI elements' font properties to be 14pt Arial, but not the usercontrol itself, so when it was drawing it on the form, it was resizing it all. Changing the usercontrol's font size to 14pt Arial, and then repositioning/resizing everything fixed it.
I started working on the UI for an app I'm making. The app has a devexpress tab control, and initially I was just placing all of my controls in there to see what it'd look like and to work out any layout issues. Well, I decide to pull out all of the ui elements for each tabpage and toss them into a UserControl and to have that UserControl fill the tab page.
The problem is that it looks perfectly normal (ie. the same as before) when in the usercontrol but when I bring that over to the tab page, all of the ui elements are HUGE (about double in size, but not exactly double).
Here's some images to show you what I mean.
Edit> Note: This is a winforms app.
UserControl:
edit > images removed
Form:
edit > images removed
It turns out that the objects are being resized. I checked the .Size property of the ui elements after the usercontrol.load event and they are much larger than they are supposed to be. This happens if there is the anchoring as I'd like it, all top-left anchored and no anchoring at all.
The AutoScaleMode of the UserControl should be at "None"...
Hard to say without seeing code...
[edit]
Well if you have no code then I only have one idea. The controls inside your user control have anchors that are being adjusted to the size of the parent control. The parent control could be larger than expected making all the anchors adjust with the parent. This would then make them all appear too big. This is my only idea...
[/edit]