Enable scrollbars in windows

I am developing a Windows forms application. In my application, I have attached controls to the forms, so that the forms can be enlarged and the controls will be arranged accordingly. This application must support different DPI values.

I set the bindings of some controls to the bottom, right, and bottom right. The AutoScroll property for forms is set to true. When the default DPI value (96) works as expected. But the problem is that the screen loads at a higher DPI (for example, 120), even if scrollbars are turned on, the controls that are attached to the lower and lower right side cannot be visible.

Can anyone advise me on this issue?

Regards, Eranga

+12
source share
4 answers

Set AutoScroll = True In Form Properties

Set AutoScroll = true on form

+27
source

for example, suppose we have a panel that has id "panel1"
then we can apply as

 panel1.autoscroll=true; panel1.BorderStyle = BorderStyle.FixedSingle; 

to set the width and height of the scroll

 panel1.SetAutoScrollMargin(int x,int y); 
+11
source

This is an old post, but the problem continues, and related messages only keep coming to SO !

I am making a necropic problem here, and I am not considering a more recent issue just because it comes on top of my google search

The question is simple: "why won't the damn scrollbars on my ScrollableControl ?"

But there can be no concrete, definitive answer. Because the cause is the legions. Because regardless of whether scrollbars appear in the control:

  • not only on your own property settings
  • but also by the state of his parental control
  • as well as the status of any child controls.

It is easy to fall into the trap of randomly scrolling values ​​until the cow returns home. Or go to i / webs and hope to find some SO foos. But oh dear. Here are some related SO posts with an outstanding variety of suggested resolutions:

Horizontal scrollbar not visible in DataGridView

A horizontal scrollbar that does not appear in my text box

How to set scrollbar in windows form

How to make scrollbars appear on a resizable panel if the control is too big for it?

Scrollable form in C #, AutoScroll = true not working

How to get scrollbar in a panel in VB.Net?

There are VS-designer property page screens (for example, here) and even some extreme code-based solutions ... my favorites:

Add vertical scrollbar to panel in .NET

How to add a Vscroll control to form in Visualbasic.net?

/ sighs /


General answer

.. as a minimal github solution to learn some of the .NET scroll voodo's:

https://github.com/violet313/TestWinForms/tree/Test1-Body-Panel

This is a Visual Studio 2015 solution using the .NET4.52 framework .

In the solution, I try to create a form that responds to some dynamic text data that needs to be displayed. here is the basic layout that I am ultimately looking for:

 -------------------------------------------------- | fixed-size form header | | ------------------------------------| side | | | panel | | dynamic content panel | stuff | | | | -------------------------------------------------- | fixed-size form trailer | -------------------------------------------------- 

I need a form:

  • cannot be changed by user
  • respond to dynamic content:

    • reduced as little as possible to the minimum size of the form.
    • growth to a given maximum size of the form; and then providing the corresponding scroll bars in the dynamic content panel.

Grab it, go through each of (only 9, starting at 95dccc5), and then test your requirements in a reasonable and incremental way. Remember to fork out when you make a dubious state change.

Irl: maybe I'm fat, but it took me more than an hour reading MSDN trying (and not being able to) figure out what unforeseen circumstances were when controlling .NET form. making a structured trial and error, so it took me only 20 minutes to get what I wanted.


y~bwc

I know it's yeaz ~ here , but who cares? but I should have gotten off with my chest. heh:

grrr. The need to cancel the answer and answer this question arises from my need to profitably take on Microsoft contract work. cashiers can be relatively (from the pov developer) non-technical and, after reading the lots including the words: fast, simple, direct, safe, etc., they leave with the impression that .NETish things are a walk to the park. My problem is that I will then have difficulty trying to reasonably explain why they might have to pay me for the n-day worth of getting a simple scrollbar that appears on a responsive form.

On this occasion, I never got there. lol. I spent several hours making my way to the MSDN blahs trying to achieve this. and then yawned, refused and advanced with a pragmatic implementation. which was accepted. but now it's w / end, and I'm a fool who can't let things be.

+3
source

I read this page and I can say that it provides an accurate and simple solution to your problem!

I checked it and it worked well for me.

Instruction:

  1. Add the manifest file to your project ( Project β†’ New Item β†’ Choose manifest type)
  2. Add the following XML to your app.manifest (maybe a different name):
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" > <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> </assembly> 
  1. Add the following C # code to the class where you call the initialize component ( InitializeComponent(); )
 [DllImport("shcore.dll")] static extern int SetProcessDpiAwareness(_Process_DPI_Awareness value); enum _Process_DPI_Awareness { Process_DPI_Unaware = 0, Process_System_DPI_Aware = 1, Process_Per_Monitor_DPI_Aware = 2 } 
  1. Now just add this line of code above the component initialization method (default is InitializeComponent(); )
 SetProcessDpiAwareness(_Process_DPI_Awareness.Process_DPI_Unaware); 
0
source

Source: https://habr.com/ru/post/912462/


All Articles