error in data grid  
Author Message
cisco0407





PostPosted: Visual C# General, error in data grid Top

The code below is for when you click on a cell. However I keep getting a index error why

The error happends here

DataGridViewRow row = Parm_dataGridView1.Rows[e.RowIndex];

says index must be

System.ArgumentOutOfRangeException was unhandled
Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
Source="mscorlib"
ParamName="index"
StackTrace:
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Windows.Forms.DataGridViewRowCollection.SharedRow(Int32 rowIndex)
at System.Windows.Forms.DataGridViewRowCollection.get_Item(Int32 index)
at icxprotype1.Stationstatus.ShowDetil_Click(Object sender, DataGridViewCellEventArgs e) in C:\Documents and Settings\Francis Jackson\Desktop\string\WindowsApplication12\Stationstatus.cs:line 473
at System.Windows.Forms.DataGridView.OnCellContentClick(DataGridViewCellEventArgs e)
at System.Windows.Forms.DataGridView.OnCommonCellContentClick(Int32 columnIndex, Int32 rowIndex, Boolean doubleClick)
at System.Windows.Forms.DataGridViewCell.OnMouseUpInternal(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnCellMouseUp(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
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.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 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 icxprotype1.SplashPage.Main() in C:\Documents and Settings\Francis Jackson\Desktop\string\WindowsApplication12\SplashPage.cs:line 31
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

private void ShowDetil_Click(object sender, DataGridViewCellEventArgs e)

{

DataGridViewRow row = Parm_dataGridView1.Rows[e.RowIndex];

DataGridViewCell cell = row.Cells[e.ColumnIndex];

Debug.WriteLine(cell.Value);



Visual C#20  
 
 
cisco0407





PostPosted: Visual C# General, error in data grid Top

i fixed it. It was a syntax error in a name i used

Cisco