私は1つのDataGridViewを持つフォームを持っています。 DGVはDataTableにバインドされ、フォームに約32,000レコードが読み込まれると入力されます。DataGridViewスクロールバーArgumentOutOfRange例外を投げる
ユーザーがスクロールバーを下にドラッグし、マウスカーソルがスクロールバーの下の下矢印の上にあるときにマウスボタンを離した場合、以下の例外が発生します。
マウスボタンが画面下部などの他の場所でリリースされた場合は、ステータスバーの時計を基準にして、例外はスローされません。最後のレコードをクリックしてスクロールバックできます。
また、スクロールバーを一番下にドラッグすると、「安全な」領域でマウスボタンを放してからもう一度スクロールして下矢印のボタンを放すと、例外はスローされません。
ソリューション内のすべてのDataGridViewが同じパラメータでセットアップされています。私は同じレコード以上の他のDGVを持っており、彼らはこれをしません。
スクロールバーについて最大値マイクロソフトでは、「最大値にはプログラムによってのみ到達できます。スクロールバーの値は、実行時のユーザー操作によって最大値に到達できません。
コード内のスクロールバーの値を操作していません。
私はこれについて何かを見つけることができません。私は誰かがこの問題のトラブルシューティングのための正しい方向で私を指すことができることを願っています。
System.ArgumentOutOfRangeException was unhandled Message=Value of
'2612103' is not valid for 'Value'. 'Value' should be between
'minimum' and 'maximum'. Parameter name: Value
Source=System.Windows.Forms ParamName=Value StackTrace:
at System.Windows.Forms.ScrollBar.set_Value(Int32 value)
at System.Windows.Forms.ScrollBar.DoScroll(ScrollEventType type)
at System.Windows.Forms.ScrollBar.WmReflectScroll(Message& m)
at System.Windows.Forms.ScrollBar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr aram, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd,
Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollBar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at VWBSMS.Program.Main() in C:\Documents and Settings\courtp\My Documents\Development\C++_DLL_Projects\VWBSMS\VWBSMS\MDIForms\Program.cs:line
21
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() InnerException:
グリッドビュー
this.dtGrid.AllowUserToAddRows = false;
this.dtGrid.AllowUserToDeleteRows = false;
this.dtGrid.AutoGenerateColumns = false;
this.dtGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dtGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.idCol,
this.lineColumn,
this.lineCol,
this.eqpCol,
this.minColumn,
this.eqptColumn,
this.rpNameCol,
this.malCol,
this.solutionColumn,
this.ltColumn,
this.faultColumn,
this.originatorCol,
this.dateCol,
this.timeDownCol,
this.dateUpCol,
this.timeUpCol,
this.T2ID,
this.T1ID,
this.threeCodeCol,
this.respCol});
this.dtGrid.ContextMenuStrip = this.gvContextMenut;
this.dtGrid.DataSource = this.dTMPNewBindingSource;
this.dtGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.dtGrid.Location = new System.Drawing.Point(0, 0);
this.dtGrid.Name = "dtGrid";
this.dtGrid.ReadOnly = true;
this.dtGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dtGrid.Size = new System.Drawing.Size(980, 360);
this.dtGrid.TabIndex = 115;
基本クラスの書式すべてgridviewsが渡されること。コンストラクタにここで設定されている
dgvA.AllowUserToAddRows = false;
dgvA.AllowUserToDeleteRows = false;
dgvA.AllowUserToOrderColumns = true;
dgvA.AllowUserToResizeColumns = true;
dgvA.AllowUserToResizeRows = false;
dgvA.RightToLeft = System.Windows.Forms.RightToLeft.No;
dgvA.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
// Main Grid Settings
dgvA.BackgroundColor = SystemColors.Control;
dgvA.BorderStyle = BorderStyle.None;
dgvA.GridColor = SystemColors.ActiveBorder;
// ************* Column Headers **********************
// General Settings
dgvA.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised;
dgvA.ColumnHeadersHeight = 20; // Based on a Tahoma font of 9
dgvA.ColumnHeadersVisible = true;
dgvA.Cursor = Cursors.Default;
dgvA.EnableHeadersVisualStyles = true;
// Column Headers Default Cell Style
dgvA.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvA.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.Control;
dgvA.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.WindowText;
dgvA.ColumnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.MenuHighlight;
dgvA.ColumnHeadersDefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
// ********************** ROWS ************************
// Alternating Rows Default Cell Style
dgvA.AlternatingRowsDefaultCellStyle.BackColor = SystemColors.Info;
dgvA.AlternatingRowsDefaultCellStyle.ForeColor = SystemColors.WindowText;
// Row Headers
dgvA.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised;
dgvA.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
dgvA.RowHeadersDefaultCellStyle.BackColor = SystemColors.Control;
dgvA.RowHeadersDefaultCellStyle.ForeColor = SystemColors.WindowText;
dgvA.RowHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Highlight;
dgvA.RowHeadersDefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
dgvA.RowHeadersVisible = false;
// ************* Default Cell Style ******************
dgvA.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvA.DefaultCellStyle.BackColor = SystemColors.Window;
dgvA.DefaultCellStyle.ForeColor = SystemColors.WindowText;
dgvA.DefaultCellStyle.SelectionBackColor = SystemColors.Highlight;
dgvA.DefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
dgvA.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
base.gridThemeSet(dtGrid);
DataGridViewCellStyle myStyle = new DataGridViewCellStyle();
myStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
malCol.DefaultCellStyle = myStyle;
診断をするためにコードの一部を見る必要があると感じています。 – deutschZuid
更新:データグリッドがあるパネルのサイズを変更し、フォームの端から離れて移動することで、問題をマスクしました。 @ジェームズ。私はどのコードを追加するか分からない。私は問題がDGVのコードにあるとは思わない、そのすべてが生成された。どのようなコードを見たいですか? – Kassabba
グリッドビューの構築とコードの書式設定が追加されました。私はいくつかの人々にこれを見ていたし、フォームに関連してGridviewの書式を調整する以外の解決策を考え出すことはできません。この問題は「スクロールバーの値が実行時にユーザーのやりとりによって最大値に到達できません」という例外ルールに違反しているため、C#コードではそのコードが間違っているとは思わないが、それを理解することができます。 – Kassabba