diff --git a/DoubleBufferPanel.cs b/DoubleBufferPanel.cs index 531c0ed..4d84475 100644 --- a/DoubleBufferPanel.cs +++ b/DoubleBufferPanel.cs @@ -1,4 +1,6 @@ using System; +using System.ComponentModel; +using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -17,8 +19,7 @@ namespace CsvView ControlStyles.SupportsTransparentBackColor , true); } - - + [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam); @@ -37,5 +38,19 @@ namespace CsvView Refresh(); } + [DefaultValue(false)] + [Localizable(false)] + [Category("CatLayout")] + [Description("DisableAutoScrollDescr")] + public bool DisableAutoScroll { get; set; } + + protected override Point ScrollToControl(Control activeControl) + { + if (DisableAutoScroll) + { + return DisplayRectangle.Location; + } + return base.ScrollToControl(activeControl); + } } } diff --git a/FrmCsvViewer.Designer.cs b/FrmCsvViewer.Designer.cs index c01265e..2bea46c 100644 --- a/FrmCsvViewer.Designer.cs +++ b/FrmCsvViewer.Designer.cs @@ -170,6 +170,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.pnlData.AutoScroll = true; this.pnlData.Location = new System.Drawing.Point(0, 37); + this.pnlData.DisableAutoScroll = true; this.pnlData.Name = "pnlData"; this.pnlData.Size = new System.Drawing.Size(508, 432); this.pnlData.TabIndex = 11; diff --git a/FrmCsvViewer.cs b/FrmCsvViewer.cs index 5194f1a..04f6e9f 100644 --- a/FrmCsvViewer.cs +++ b/FrmCsvViewer.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Runtime.InteropServices; using System.Windows.Forms; namespace CsvView @@ -150,6 +149,7 @@ namespace CsvView pnlData.SuspendDrawing(); + pnlData.VerticalScroll.Value = 0; pnlData.Controls.Clear(); _currentReg = currentReg; txtCurrentReg.Text = Convert.ToString(currentReg); @@ -208,6 +208,7 @@ namespace CsvView pnlData.SuspendDrawing(); + pnlData.VerticalScroll.Value = 0; pnlData.Controls.Clear(); pnlReg.Enabled = false; txtCurrentReg.Text = string.Empty;