Datagridview Error Index 1 Does Not Have A Value
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and datagridviewrow index policies of this site About Us Learn more about Stack Overflow the system.windows.forms.currencymanager.get_item(int32 index) company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags datagridview index does not have a value 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 datagridviewrow index=-1 c# takes a minute: Sign up Index-1 does not have a value up vote 9 down vote favorite 2 I'm getting the strangest error I am absolutely clueless about. I'll post a description along with some code here, and hopefully one of you guys can point me in the right direction. My app (Winforms), allows a user to add items to a
System.windows.forms.datagridview.datagridviewdataconnection.geterror(int32 Rowindex)
datagridview (bound to a list), and everytime an item is added, the list is serialized to a xml file. When the application is initially launched, the program checks for the xml file, and if found, adds the previously added items to the dgv. Ive also added a DataGridViewButtonColumn to delete items from the dgv (list). Here is some of the code. Main class: static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new formFoldingClient()); } The form's constructor calls this method to initially set up the dgv private void InitialDataGridViewSetup() { dgvClients.DataSource = null; //adding delete button column DataGridViewButtonColumn btnDelete = new DataGridViewButtonColumn(); btnDelete.Name = "btnDelete"; btnDelete.Text = "Delete"; btnDelete.HeaderText = "Delete"; btnDelete.UseColumnTextForButtonValue = true; btnDelete.DefaultCellStyle.BackColor = Color.DarkBlue; btnDelete.DefaultCellStyle.ForeColor = Color.White; dgvClients.Columns.Add(btnDelete); RefreshDataGridView(); } Everytime an item is added or removed, the dgv is refreshed by calling this method: private void RefreshDataGridView() { dgvClients.DataSource = null; if (clientList.Count != 0) { dgvClients.DataSource = clientList; dgvClients.Show(); dgvClients.ClearSelection(); } } Method that gets triggered when Delete button on a row in the dgv is pressed, followed by the method the performs the delete private void dgvClients_CellClick(obj
here for
Datagridview Index 0 Does Not Have A Value
a quick overview of the site Help Center system.indexoutofrangeexception index does not have a value 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 http://stackoverflow.com/questions/4965963/index-1-does-not-have-a-value 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 of 4.7 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/27467479/c-sharp-datagridview-index-1-does-not-have-a-value takes a minute: Sign up c# datagridview index -1 does not have a value up vote 0 down vote favorite I have a strange exception. Sometimes - not all the times, when clicking a datagridview, I get this exception: System.IndexOutOfRangeException: Index -1 does not have a value. at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) 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.OnCellMouseDown(HitTestInfo hti, Boolean isShiftDown, Boolean isControlDown) at System.Windows.Forms.DataGridView.OnCellMouseDown(DataGridViewCellMouseEventArgs e) at System.Windows.Forms.DataGridView.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(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.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr l param) The grid is re populated automatically from a
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View http://www.codeproject.com/Questions/540529/I-mplusgettingplusthispluserror Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting does not and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox does not have Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ I'm getting this error: "Index -1 does not have a value." when clicking a combobox Rate this: Please Sign up or sign in to vote. See more: C# Windows .NET form windows.forms I'm getting this error when i click on the combobox (dropdown) the grid view in the winforms. Index -1 does not have a value. Please help me in this... I'm Stuck for a long time... No luck in googling. :( Thanks. Posted 4-Feb-13 22:02pm Velrats1.3K Updated 4-Feb-13 23:37pm Joezer BH38.7K v2 Add a Solution Comments naveensenagasetti 5-Feb-13 4:07am post your code.. please TheOtherCPian 5-Feb-13 4:12am Not much we can do without seeing some code, but index -1 means nothing is selected. Hope that helps you figure it out. TheOtherCPian 5-Feb-13 4:22am I don't understand your comment. Can you please rephrase it