473,734 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help to solve "Index was outside the bounds of the array." error

5 New Member
i am getting "Index was outside the bounds of the array." error when i try to get the checked items from list view.
the code is
Expand|Select|Wrap|Line Numbers
  1. private void btnFinish_Click(object sender, EventArgs e)
  2. {
  3. WaitCallback async = new WaitCallback(Executefeed);
  4. ThreadPool.QueueUserWorkItem(async, alParams);
  5. waitBar.ShowDialog();
  6. }
  7.  
  8. private void ExecuiteDataFeed(object param)
  9. {
  10. ArrayList alParams = (ArrayList)param;
  11.  
  12. if(this.lstInvoiceTran.CheckedItems.Count > 0)
  13. {
  14. this.m_InvoiceSelection = null;
  15. for ( int y = 0; y < lstInvoiceTran.CheckedItems.Count; y++ )
  16. {
  17. this.m_InvoiceSelection += this.lstInvoiceTran.CheckedItems[y].SubItems[0].Text;
  18. this.m_InvoiceSelection += ", ";
  19. }
  20.  
  21. m_InvoiceSelection = m_InvoiceSelection.Remove(m_InvoiceSelection.Length - 2, 2);
  22. m_InvoiceSelection = m_InvoiceSelection.Replace(" ","");
  23. }
  24. }
  25.  
when i debug, " lstInvoiceTran. CheckedItems.Co unt" in the FOR loop is failing.
please help.
Jul 23 '08 #1
3 2089
r035198x
13,262 MVP
What's this.m_InvoiceS election = null; for?

P.S That part can't be responsible for the execption. The exception is thrown in one of your array index accesses.
Jul 23 '08 #2
kalaivani572
5 New Member
What's this.m_InvoiceS election = null; for?

P.S That part can't be responsible for the execption. The exception is thrown in one of your array index accesses.
thats rite.
In debug mode, when the cursor in the button click event, through command window, if i access"lstInvoi ceTran.CheckedI tems.Count", then it is giving the exact count.
But if i do the same inside "ExecuteFee d" function, in command window "Cannot Obtain Value" error appears and then the above exception is thrown in application.
can u please clarify whether the "Listview" property cant be used inside a function?
Jul 23 '08 #3
Plater
7,872 Recognized Expert Expert
I am thinking it is angry because you are doing this in a "threaded" context.
You might have to look for synclocks or just plain mutexs to keep it from being angry about your non-threadsafe access?
Jul 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
10780
by: kim | last post by:
Scenario (I'm a newbie): I have a datagrid with countries listed and 5 parameters in each row. I want to add a row to this datagrid via an Event Handler. Very basic stuff. This method then call a Business method, which calls a Data method which calls an SP in MS SQL. My code compiles well, but the page throws "Index was outside the bounds of the array". I really can't figure why, take a look maybe you pros see can read between the...
0
2759
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid, binded to dataview. Here's a catch - whenever I select a client, and then find a car which belongs to this client, and click on empty space in datagrid (that is in gray area below rows) - I get "Index was outside the bounds of the array" error......
2
2260
by: David Laub | last post by:
A transform that works fine in XMLSPy fails when I run it under dot net. I've run many other transforms successfully in dot net so there is something "special" about this transform I just installed dot net framework 1.1 SP1 - but I still get the same error What makes this transform more complex than others is: 1) It uses an MSXSL extension function to evaluate Xpaths at run time 2) It uses an include to include the extension function 3)...
1
3555
by: melinda | last post by:
How do you set up a MDI interface so that one of the MDI forms can be dragged outside of the parent form. For example, in Visual Studio, you can do this with some of the windows. Is this MDI? Or how do you that in C#.net?
1
2533
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to track down this error, but none of them really explain this problem/solution very well. I tried hard to debug this, but debuggin itself was impossible. The error message is as follows:
1
1938
by: Dave | last post by:
I'm getting the following error on an EditCommand event. This code is running on production web farm and the thing is it doesn't happen all the time. If I get this error, click the back button, and try again it works. Sometimes it works the first time in. I tried to step through the debugger running locally but I can't duplicate it. Server Error in '/' Application. ---------------------------------------- Index was out of range. Must...
0
1299
by: Trapulo | last post by:
I've a datagrid filled with a collection of objects that inherits from basecollection. When I remove an item from this collection and then click onto the datagrid, I've always this error: "Index was outside the bounds of the array datagrid" I've tried this structure: Dim oldList As Business.MyBaseCollection = DirectCast(dgDetails.DataSource,
3
3160
by: writebrent | last post by:
I wrote a little interface for users to post data to a website. On their local machines, it produces CSV from an Excel spreadsheet, then posts it to the site. In some cases, the CSV will contain ampersands. For example, abc,American & British Company,1,4.34,5 ded,Dog Eat Dog,2,6.3,5.766 The code on the site is pretty standard: it loops through an array of lines from the CSV split on line ends, and then loops through another
2
5521
by: Dave Strydom | last post by:
Hi, I'm getting the following error in my event log: ============ Event Type: Error Event Source: Active Server Pages Event Category: None Event ID: 5 Date: 2007/03/09 Time: 11:50:48 AM
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.