C# Datagridview Currencymanager Error
Contents |
here for a quick overview of the system.windows.forms.datagridview.datagridviewdataconnection.geterror(int32 rowindex) site Help Center Detailed answers to any questions datagridviewrow index=-1 c# you might have Meta Discuss the workings and policies of this site About Us datagridview index 0 does not have a value Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Datagridview System.indexoutofrangeexception Index 0 Does Not Have A Value
Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up DataGridView binding problem: “Index -1 does not have datagridview index does not have a value a value.” up vote 4 down vote favorite I have a datagridview bound to a binding source and a couple buttons on a form. One button adds an item to the binding source, the other removes the currently selected item. There's also an event handler that listens to the CurrentChanged event and updates the Enabled status of the Remove button. Everything is hunky dory until I go to remove the last item from the datagridview. Then I see a very ugly exception: at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at System.Windows.Forms.CurrencyManager.get_Current() at System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowEnter(DataGridViewCellEventArgs e) at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canCreateNewRow, Boolean validationFailureOccurred) at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) at System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick, Boolean clearSelection, Boolean forceCurrentCellSelection)\r\n at System.Windows.Forms.DataGridView.MakeFirstDisplayedCellCurrentCell(Boolean includeNewRow) at System.Windows.Forms.DataGridView.OnEnter(Ev
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community http://stackoverflow.com/questions/3687820/datagridview-binding-problem-index-1-does-not-have-a-value of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up DataGrid throws IndexOutOfRangeException from CurrencyManager when any cell clicked up vote 3 down vote favorite 3 I have a data grid on a windows form. When I initially update that grid to contain data, http://stackoverflow.com/questions/7810149/datagrid-throws-indexoutofrangeexception-from-currencymanager-when-any-cell-clic and then click on it, I get the below exception. Notably the exception is deep down in the windows handling of the form, and so the exception is caught at the point whereby I launch the form. Please note, I had to tick "Show External Code" in the Call Stack to show the Call Stack below, otherwise it just shows [External Code]. In terms of hunches/troubleshooting steps, thinking that it may have been caused by a message that is fired for the item which was selected and then the item which is now selected, I have tried to .SelectAll(); on the DataGridView after updating the data, this had the same results. The Exception: IndexOutOfRangeException {"Index -1 does not have a value."} The Call Stack: System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.this[int].get(int index) + 0xa1 bytes System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.Current.get() + 0x16 bytes System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowEnter(System.Windows.Forms.DataGridViewCellEventArgs e) + 0x101 bytes System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnRowEnter(ref System.Windows.Forms.DataGridViewCell dataGridViewCell = null, int columnIndex = 1, int rowIndex = 0, bool canCreateNewRow, bool validationFailureOccurred) + 0x218 bytes System.Windows.Forms.dll!System.Windows.Forms.DataGridView.Se
Studio 2015 products Visual Studio Team Services Visual Studio Code Visual Studio Dev Essentials Office Office Word/Excel/PowerPoint Microsoft Graph Outlook OneDrive/Sharepoint Skype Services Store Cortana Bing Application Insights Languages & platforms Xamarin https://social.msdn.microsoft.com/Forums/windows/en-US/1e1b048f-ffa2-4001-8a59-42c496572e6c/indexoutofrangeexception-on-datagridview?forum=winformsdatacontrols ASP.NET C++ TypeScript .NET - VB, C#, F# Server Windows Server SQL Server BizTalk Server SharePoint Dynamics Programs & communities Students Startups Forums MSDN Subscriber downloads Sign in Search Microsoft Search Windows Dev Center Windows Dev Center Explore What’s new for Windows 10 Intro to Universal Windows Platform Coding challenges Develop for accessibility Build for enterprise Windows Store opportunities Docs Windows apps Get started Design does not and UI Develop API reference Publish Monetize Promote Games Get started UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Why Windows Dashboard Explore What’s new for Windows 10 Intro to Universal Windows Platform Coding challenges Develop for accessibility Build for enterprise Windows Store opportunities Docs Windows apps Get started does not have Design and UI Develop API reference Publish Monetize Promote Games Get started UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Why Windows Dashboard Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Asked by: IndexOutOfRangeException on DataGridView Windows Forms > Windows Forms Data Controls and Databinding Question 0 Sign in to vote Hello, I've come across a problem that's been driving me nuts for the past couple days. I'll explain first what this part of the form is being used for. Have two datagridviews that is giving me status information about another piece of software I'm monitoring. The first dgv is used just to report an Online / Offline status. The Second is used to give me vital stats about all the machines running that software (IPAddress, CPU Usage, Memory available, Memory used, Total Memory,....). I have a class that polls for that status every 5 seconds. Once it's finished polling, I call my form and pass a dataset containing two datatables. At that point I'm se