Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Autoscroll for usercontrol

$
0
0

Hello everyone,

I am designing an application where I want to use a user control which should be scrollable. After several hours of internet searching and trying out different settings I consider myself defeated and I would like to ask for your help.

So here is the problem: My user control is contained inside a tab control on the main form. The user control displays a series of charts, which are generated dynamically based on user input. Usually the number of charts is large enough that the entire area of the user control containing all charts extends far beyond. Therefore scrolling should be enable in order to view the entire area of the controls containing all charts. This does not seem to work. I have tried (all) possible combinations of setting AutoScroll = true|false, AutoSize=true|false; DockStyle=Fill|None, and various settings for AutoScrollMinSize. But nothing seems to work: my user control is displayed only as far as the main form and the auto scroll is only enable when I shrink the window.

This is how I defined my control in the main form:

this.histPortfoliosOut1.AutoScroll = true;
//this.histPortfoliosOut1.AutoSize = true;
this.histPortfoliosOut1.AutoScrollMinSize = new System.Drawing.Size(836, 580);
this.histPortfoliosOut1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.histPortfoliosOut1.Dock = System.Windows.Forms.DockStyle.Fill;
this.histPortfoliosOut1.Location = new System.Drawing.Point(3, 3);
this.histPortfoliosOut1.Name = "histPortfoliosOut1";
//this.histPortfoliosOut1.Size = new System.Drawing.Size(933, 580);
this.histPortfoliosOut1.TabIndex = 0;

And this is a piece of the code where I fill the user control with charts:

System.Windows.Forms.DataVisualization.Charting.Chart chart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.SuspendLayout();
chart.Location = new System.Drawing.Point(m_charts[m_charts.Count - 1].Left,
m_charts[m_charts.Count - 1].Top + m_charts[m_charts.Count - 1].Height + 15);
chart.Size = new System.Drawing.Size(m_charts[m_charts.Count - 1].Width, 220);
this.Controls.Add(chart);
chart.Visible = false;
m_charts.Add(chart);
this.Size = new System.Drawing.Size(this.Width, this.Height + chart.Height + 15);
this.ResumeLayout(true);

Many thanks in advance. Regards,

Valentin


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>