List view On Selected Index Changed Event

Hello, I do have the following code in ListView_ON Click even which is working just fine. glbRelationID = ListView2.SelectedItems.Item(0).SubItems(1).Text When I try to place the same code in ListView_On_Selected_Index_Changed event I receive an error. Does anyone know what I should change. Thank you. Peter

4 Replies

SU suda November 21, 2003 06:49 PM UTC

> Hello, > I do have the following code in ListView_ON Click even which is working just fine. > > glbRelationID = ListView2.SelectedItems.Item(0).SubItems(1).Text > > When I try to place the same code in ListView_On_Selected_Index_Changed event I receive an error. Does anyone know what I should change. Thank you. > Peter > > Hi peter add this line before if selectedindex = -1 exit sub It will solve your problem


AD Administrator Syncfusion Team November 22, 2003 08:38 PM UTC

Hi Suda. Thank you for the responce. Actually I'm not trying to avoid the error. I would like to select the item when the index Changes. Please advise. Thank you.


SU suda November 24, 2003 06:37 PM UTC

Hi peter, When Selected Index = -1 then SelectedItems Property will Return an Exception, I am also working around that if you don't select any value also it is throws an Exception error,Other than that it is working for me any other alternative please post it I will have a look. Thank you Peter Hello, > I do have the following code in ListView_ON Click even which is working just fine. > > glbRelationID = ListView2.SelectedItems.Item(0).SubItems(1).Text > > When I try to place the same code in ListView_On_Selected_Index_Changed event I receive an error. Does anyone know what I should change. Thank you. > Peter > > Hi peter add this line before if selectedindex = -1 exit sub It will solve your problem


AD Administrator Syncfusion Team December 11, 2003 01:55 AM UTC

I understand that but how do you know which item is bein selected?

Loader.
Up arrow icon