473,327 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Help on C# index problem

navanova
Hi Guys, I keep on having an error message that says "InvalidArgument=Value of '-1' is not valid for 'index'.
Parameter name: index"

Can anybody tell me what the problem is please?

The part of the code that the generates an ArugmentOutOfRangeException is as follows:

for (int k = 0; k < irrfound; k++)
{
string irrdescription = dtirrviolated.Rows[k]["IrrDescription"].ToString();
int index = clbIrregularity.FindStringExact(irrdescription, -1);
clbIrregularity.SetItemChecked(index, true);

}

Note that dtirrviolated is a datatable that contains lists of data from the database. clbIrregularity is the name of my checked listbox on which the data from the database is displayed.

Thanks,
Jul 3 '08 #1
4 1255
shweta123
692 Expert 512MB
Hi,

You are getting this error because index of the item you have supplied for SetItemChecked method is not valid. You can specify the index value as zero or greater than zero.
Please check that if value of IrrDescription column in db is not Null or not empty.You have to write code for checking database value before doing SetItemChecked.
Jul 3 '08 #2
Hi,

You are getting this error because index of the item you have supplied for SetItemChecked method is not valid. You can specify the index value as zero or greater than zero.
Please check that if value of IrrDescription column in db is not Null or not empty.You have to write code for checking database value before doing SetItemChecked.


How can I specify the index value to zero or greater than zero?

Thanks,
Jul 3 '08 #3
Plater
7,872 Expert 4TB
Try:
Expand|Select|Wrap|Line Numbers
  1. if (index>-1)
  2. {
  3.    clbIrregularity.SetItemChecked(index, true);
  4. }
  5.  
Jul 3 '08 #4
Try:
Expand|Select|Wrap|Line Numbers
  1. if (index>-1)
  2. {
  3.    clbIrregularity.SetItemChecked(index, true);
  4. }
  5.  
Dear Plater,

You are Incredibly the best programmer. It finally works!!!

Thankyou and God bless you!!
Jul 3 '08 #5

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

Similar topics

1
by: Mario Rosario | last post by:
Hi, Thanks in advance for your help. I have a compile problem; actually a link problem, when I compile the class template below. I would appreciate if anyone can tell me what is wrong and how...
6
by: Paul | last post by:
Not sure if this is the correct place to post the problem, but trying to use the HTML help workshop and trying to create the index file automatically. Anyhow I get the error below HHC5003: Error:...
3
by: Woody Splawn | last post by:
For reasons I have not yet identified my Help, Search and Help, Index has quit working. That is, in the VB IDE, from the Help menu, I can select Dynamic help or Contents and things work as...
4
by: jereme.goblue | last post by:
The web page at http://www.rossowinspections.com/ has an issue with the left menu. The left menu has 7 links. One of the links doesn't work. Using Firefox 1.5 the Fees link isn't a clickable...
7
by: Sheldon | last post by:
Hi, I have the following loop that I think can be written to run faster in Numeric. I am currently using Numeric. range_va = main.xsize= 600 main.ysize= 600 #msgva is an (600x600) Numeric...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
5
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
3
by: CaseT | last post by:
Hi, My company's website is down so I'm hoping someone has seen this bizarre problem/behavior before and can help me out .. We have a USA and an International site. Two directories under the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.