Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a listbox that contains Courses like


1 Oracle
3 PLSQL
4 Oracle 11g DBA
10 Unix
11 Unix Admin

These courses{Course Name and course ID} are coming from Database.

My intention is to select Oracle and PLSQL for that

I used the below code
listViewBox1.Items[1].Selected = true;
listViewBox1.Items[3].Selected = true;

But it is treating 1 as PLSQL and 3 as Unix.
Posted
Comments
[no name] 25-Apr-14 9:15am    
Yes... that would be correct since arrays are 0 based.
Venkat Kumar chigulla 25-Apr-14 9:16am    
Is there any solution for this..?

1 solution

Hello,

Are you having a problem interpreting the array of items.

Consider the array as follows:

0 - [1 Oracle]
1 - [3 PLSQL]
2 - [4 Oracle 11g DBA]
3 - [10 Unix]
4 - [11 Unix Admin]

When you write listViewBox1.Items [1] Selected = true.; you obtain: 1 - [3 PLSQL]

Likewise when you write listViewBox1.Items [3] Selected = true.; you obtain [10 Unix]

Probably want to choose the value for ID. There is a method for this purpose.

JAFC
 
Share this answer
 
Comments
Venkat Kumar chigulla 25-Apr-14 9:28am    
What is that method..? Any sample code
José Amílcar Casimiro 25-Apr-14 10:07am    
Check this: http://stackoverflow.com/questions/13367818/set-selected-item-of-listview-according-to-a-value

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900