Split Container Anchor issues in VS2010 - vb.net

I have had multiple projects where the UI seems to become "corrupt" in the designer. It always seems to pertain to split containers, DataGridViews, and anchoring the DGV inside the split container. It seems the DGV anchor somehow becomes de-synced and the DGV grows larger than the Panel that it is supposed to be anchored within. This causes a part of the DGV to be cut off and no scrollbar is available to see the rest.
Has anyone encountered this, and hopefully also found a fix?

The solution was to get rid of the split container. I started to remember other projects I've had issues with the designer also contained a split container.
I found a few bug reports about this on the Microsoft website and they appear to have been swept under the rug. I have a feeling this is a known issue that is not likely to get fixed.

Related

Bypass/replace event/handler for a VB.NET Windows Forms control I didn't create?

I'm working on a project that has needed a TreeView control with multiple columns. After research looked like a custom control was necessary, and to my luck I found a good one on CodeProject: https://www.codeproject.com/Articles/26849/The-TreeListView-To-End-All-TreeListViews
I've been leaning on this control heavily but have run into a few bugs that have been very challenging to work around given that I can't actually access the source code in the project files the developer was kind enough to share. The main issue I'm dealing with is a crash that pops up when the control is resized almost to the point to where a horizontal scrollbar would need to appear. I noticed that when resizing there is a deadzone of about 10 pixels where this control would show the horizontal scrollbar slightly before you'd need to, likely because of weirdness in measuring the indenting widths of child tree nodes. In this state the scrollbar appears, the scroll box fills the entire bar and won't allow you to scroll left or right.
This doesn't bother me other than the fact that if you use your mouse scroll wheel in this state it throws an ArgumentOutOfRange exception and pulls my application down:
Value of '-1' is not valid for 'Value'. 'Value' should be between
'minimum' and 'maximum'.
I'd love to be able to handle this exception but I'm quite new to VB.NET and Windows Forms and am still learning how events are handled. If there is a straightforward way to override the OnMouseWheel event or otherwise handle errors that may be triggered from it that would be fantastic. That or any other suggestions the community may have would be greatly appreciated.
If helpful, here is the top part of the error's StackTrace:
System.Windows.Forms.ScrollBar.set_Value(Int32 value)
WinControls.ListView.ContainerListView.OnMouseWheel(MouseEventArgs e)
The ListTreeView control (one I'm using) inherits from ContainerListView. ContainerListView's OnMouseWheel event is protected. Does this mean that I won't be able to override it?
Thanks, and happy to provide any other information that is needed.

Position of PictureBoxes in form design window do not correspond to their position during runtime

EDIT: I realized that I didn't tag this properly - I should have included vb.net as a tag, on the grounds that there could be a code based solution. Note, that no changes to the resolution are made in my source code.
UPDATE: When the program starts execution, the left coordinate for each PictureBox is multiplied by ~0.376, whilst the top coordinate for each PictureBox.Top is multiplied by ~0.418 . This "down-scaling" applies to all picture boxes. The source code I have is incredibly rudimentary and cannot be responsible for this. I also looked at another project and I still face the same error. A simple but poor fix would be to divide each coordinate by the corresponding values mentioned above.
In order to show you the issue I'm facing, please look at the images below. Compare this image, where each PictureBox (i.e. a snake, set of arrows, etc.) has been placed so that they line up with a feature of the background image:
To this image, where the PictureBox elements are bunched together. Their positions have been "down-scaled" closer to the origin of the form (note that all the elements are transforming horizontally during runtime, which is why the elements are in the top right corner):
In the solution I was given (developed in VS 2010 I believe), the position of each PictureBox goes beyond the background image as shown:
It is clear that each picture box has been placed in an organized fashion. During execution, each PictureBox goes to it's intended position (i.e. lines up appropriately with the background image).
Obviously, the original developer of the solution I was given would have not faced the problem I am. The fact that the solution works properly during runtime indicates some kind of error with my instance(s) of VB. Does anyone know of any solutions?
I've came across this question which asks how to change the default resolution for a Windows 8 App and this question which asks why some applications appear differently on different machines, but they pose no clear solutions. I would appreciate any help, since it's holding me back from critical work I must do. Thank you in advance!
I feel a little silly now - I started carrying out a bit more research on VB forms and came came across this Microsoft documentation on form scaling. Realizing that my issue may have been caused by having this scaling automatically carried out, I then found the AutoScaleMode property of my form and changed it from Font to None, which resolved my problem.

Nested SplitContainers bug the SplitterWidth

So I have 3 split containers, with 2 panels each.
SplitContainer1 is the main container that is docked in the Form ( Parent ).
SplitContainer1.Panel1 contains SplitContainer2 which is docked.
SplitContainer1.Panel2 contains SpliContainer3 which is docked.
So far so good.
SplitContainer1 has a SplitterWidth of 3.
SplitContainer2 and SplitContainer3 has a SplitterWidth of 6.
In the Designer, you can see the SplitterWidth difference between them, but when I build the solution, the SplitterWidth of SplitContainer2 and SplitContainer3 gets reset back to 4 no matter what I do. I have changed the code in "InitializeComponent" of the form with no effect.
The only way I got this working is in the Load Event of the form, re-specify the SplitterWidths which I find completely dumb. Why won't the SplitterWidths stay at the value I specified in the Designer?
If anyone can shed some light on this, what would be awesome!!
Thanks for your time,
Peter
Just so that this isn't left unanswered for eternity -
This is an old bug that has been in Visual Basic for many versions now, and is never addressed (nor is it likely to ever be addressed).
As Hans Passant mentions, the issue is due to the ISupportInitialize implementation for the SplitContainer.
Since it's a bug, there is not definitive way of resolving the issue that makes any logical sense.
One way, which I've tested in a mock up program, is as #xfx says - Add and manipulate the controls programmatically, rather than using the toolbox.
An alternative is to reload the SplitterWidths programatically, whether that's on Form_Load, which is most likely, or anywhere else in the code that it may be required.

How to resolve Windows Forms designer issue - controls move on debug?

Is there a reason / fix for this weird designer issue (at least, I think it's related to the designer), whereby the controls on the form do not appear as they do in the design window when I debug the application..!
Please see the following two screenshots to demonstrate the problem (note: I have blacked out some of the content of the form, this is not the problem):
Picture 1: Showing how the form appears in the designer view
Picture 2: Showing how the form appears in debug mode
You can clearly see that some of the buttons have moved position on the form.
Note: At first glance, this may appear like a duplicate of: Windows Forms Designer destroys form layout. However, I have not installed any additional tools or components. This is simply a standard "vanilla" build of Visual Studio 2012 on Windows 7 32-bit.
I've also come across this question: UI Controls Overlapping & Fonts Issue in Windows Forms Application. However, I am not using "large fonts", nor am I using any non-standard fonts on my controls (all label and button text is left as default). Still, I can see how this would affect the control positions and will do some more checks in this area.
There's nothing happening within the form's Load method.
I'm also using TFS 2012.
What could be causing this? Is there anything I can do to fix it?
EDIT: I've removed the font property for each label and button control, allowing the system to set the default value. Still no change. Interestingly, if I open the form in design mode, then save it, then close it, then open it again, the buttons have moved... If I do this a few times, the buttons migrate until they're off the form.
OK, I've found the answer, after a bit more fiddling. It seems to be related to the Anchor property on the controls. I made a bunch of changes, testing between each change to see if there was any difference. When I selected all the controls and set the Anchor property to Top, Left, this solved the issue.
I hope this helps someone else at some point!

Is there a way to 'lock' the last item in a ListView to always show?

I am listing folders and folder sizes in a ListView for a VB.NET WinForm program I'm writing. I would like to total the folder sizes in the last entry of the ListView and 'lock' it show it always shows (even if scrolling through the list.
Is there a way to do this? I'd really like to avoid adding another control on the Windows Form to display the total.
EDIT:
Space is somewhat of an issue as I'm trying to keep this window small enough to work in a min screen resolution of 800x600 (I know, waaaaay not the standard, but I want to make this available to even those in the elderly community with problematic eyesight.
Thanks!
-JFV
There appears to be ways to do this in Webforms and WPF, but not in Winforms. You should probably use a text box. Any attempt to hack in a fixed totals row would most certainly be far more effort than the benefit obtained. It is certainly beyond my capabilities. Even the custom control shops like Telerik don't seem to do this.
http://www.telerik.com/products/winforms/gridview.aspx
If you're concerned about space, make the gridview a little smaller to accomodate the text box.