473,395 Members | 1,658 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,395 software developers and data experts.

Problem deleting Last Row in ListView

I am writing mobile application using Vb.net

when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"

what does that mean ?

I can delete any row without problem but except last row only....

Nov 21 '05 #1
10 4366
Show us the code... If you are using the index for deleting you should be
adjusting by -1

Cheers
Daniel
--
http://www.danielmoth.com/Blog/
" A_PK" <pk***@hotmail.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
I am writing mobile application using Vb.net

when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"

what does that mean ?

I can delete any row without problem but except last row only....

Nov 21 '05 #2
A,

Test in your delete method if there are still enough items to delete, this
can occur when you have not done that and a delete button is pushed twice at
the end.

I hope this helps?

Cor

" A_PK" <pk***@hotmail.com>
I am writing mobile application using Vb.net

when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"

what does that mean ?

I can delete any row without problem but except last row only....

Nov 21 '05 #3
If you have 5 rows delete row number 4 as the rows are zero based. It means:
Rows: 0,1,2,3,4 (5 rows)

"A_PK" wrote:
I am writing mobile application using Vb.net

when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"

what does that mean ?

I can delete any row without problem but except last row only....

Nov 21 '05 #4

The following is the code that I delete my last row in List VIew

-----
With ListView1.FocusedItem

ListView1.Items.Remove(ListView1.Items(.Index))

End With
------

How can I set the index to -1 after i delete ?
if i only have 1 row in ListView, by adjusting index to -1 will still face
the problem since there is no record.

Pls guide

"Daniel Moth" <dm*****@hotmail.com> wrote in message
news:uG****************@TK2MSFTNGP10.phx.gbl...
Show us the code... If you are using the index for deleting you should be
adjusting by -1

Cheers
Daniel
--
http://www.danielmoth.com/Blog/
" A_PK" <pk***@hotmail.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
I am writing mobile application using Vb.net

when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"

what does that mean ?

I can delete any row without problem but except last row only....


Nov 21 '05 #5
If you allow only one item to be selected you can use this line:
If (ListView1.SelectedItems.Count > 0) Then
ListView1.SelectedItems(0).Remove()
End If

"A_PK" wrote:

The following is the code that I delete my last row in List VIew

-----
With ListView1.FocusedItem

ListView1.Items.Remove(ListView1.Items(.Index))

End With
------

How can I set the index to -1 after i delete ?
if i only have 1 row in ListView, by adjusting index to -1 will still face
the problem since there is no record.

Pls guide

"Daniel Moth" <dm*****@hotmail.com> wrote in message
news:uG****************@TK2MSFTNGP10.phx.gbl...
Show us the code... If you are using the index for deleting you should be
adjusting by -1

Cheers
Daniel
--
http://www.danielmoth.com/Blog/
" A_PK" <pk***@hotmail.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
I am writing mobile application using Vb.net

when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"

what does that mean ?

I can delete any row without problem but except last row only....



Nov 21 '05 #6
if listview only got one row, after i have deleted that row, where should i
set my index ?? and how should i set my index...

thanks you

"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
If you allow only one item to be selected you can use this line:
If (ListView1.SelectedItems.Count > 0) Then
ListView1.SelectedItems(0).Remove()
End If

"A_PK" wrote:

The following is the code that I delete my last row in List VIew

-----
With ListView1.FocusedItem

ListView1.Items.Remove(ListView1.Items(.Index))

End With
------

How can I set the index to -1 after i delete ?
if i only have 1 row in ListView, by adjusting index to -1 will still
face
the problem since there is no record.

Pls guide

"Daniel Moth" <dm*****@hotmail.com> wrote in message
news:uG****************@TK2MSFTNGP10.phx.gbl...
> Show us the code... If you are using the index for deleting you should
> be
> adjusting by -1
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> " A_PK" <pk***@hotmail.com> wrote in message
> news:Or**************@TK2MSFTNGP11.phx.gbl...
>>I am writing mobile application using Vb.net
>>
>> when i click the last row of list view, and try to delete it....
>> will promtpy the following message "Additional information:
>> ArgumentOutOfRangeException"
>>
>> what does that mean ?
>>
>> I can delete any row without problem but except last row only....
>>
>>
>>
>
>


Nov 21 '05 #7
After you have deleted your selected row (last row), the index:
listView1.SelectedIndices(0)
Will be set automatically to -1 becasause no record is selected.
"A_PK" wrote:
if listview only got one row, after i have deleted that row, where should i
set my index ?? and how should i set my index...

thanks you

"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
If you allow only one item to be selected you can use this line:
If (ListView1.SelectedItems.Count > 0) Then
ListView1.SelectedItems(0).Remove()
End If

"A_PK" wrote:

The following is the code that I delete my last row in List VIew

-----
With ListView1.FocusedItem

ListView1.Items.Remove(ListView1.Items(.Index))

End With
------

How can I set the index to -1 after i delete ?
if i only have 1 row in ListView, by adjusting index to -1 will still
face
the problem since there is no record.

Pls guide

"Daniel Moth" <dm*****@hotmail.com> wrote in message
news:uG****************@TK2MSFTNGP10.phx.gbl...
> Show us the code... If you are using the index for deleting you should
> be
> adjusting by -1
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> " A_PK" <pk***@hotmail.com> wrote in message
> news:Or**************@TK2MSFTNGP11.phx.gbl...
>>I am writing mobile application using Vb.net
>>
>> when i click the last row of list view, and try to delete it....
>> will promtpy the following message "Additional information:
>> ArgumentOutOfRangeException"
>>
>> what does that mean ?
>>
>> I can delete any row without problem but except last row only....
>>
>>
>>
>
>


Nov 21 '05 #8
yes....when there is no record selected, then when i trigger
listview1.focuseditem.text then i will encounter problem....

after i delete my last row record, the system always trigger the event
listview1.selectedindexchanged, under that i got coding like
listiview1.focuseditem.text, so i will have problem

how could i avoid that...

when no record is being selected, then i dun want to trigger that
listview1.focuseditem.text

thank you
"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
After you have deleted your selected row (last row), the index:
listView1.SelectedIndices(0)
Will be set automatically to -1 becasause no record is selected.
"A_PK" wrote:
if listview only got one row, after i have deleted that row, where should
i
set my index ?? and how should i set my index...

thanks you

"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
> If you allow only one item to be selected you can use this line:
> If (ListView1.SelectedItems.Count > 0) Then
> ListView1.SelectedItems(0).Remove()
> End If
>
>
>
> "A_PK" wrote:
>
>>
>> The following is the code that I delete my last row in List VIew
>>
>> -----
>> With ListView1.FocusedItem
>>
>> ListView1.Items.Remove(ListView1.Items(.Index))
>>
>> End With
>> ------
>>
>> How can I set the index to -1 after i delete ?
>> if i only have 1 row in ListView, by adjusting index to -1 will still
>> face
>> the problem since there is no record.
>>
>> Pls guide
>>
>>
>>
>> "Daniel Moth" <dm*****@hotmail.com> wrote in message
>> news:uG****************@TK2MSFTNGP10.phx.gbl...
>> > Show us the code... If you are using the index for deleting you
>> > should
>> > be
>> > adjusting by -1
>> >
>> > Cheers
>> > Daniel
>> > --
>> > http://www.danielmoth.com/Blog/
>> >
>> >
>> > " A_PK" <pk***@hotmail.com> wrote in message
>> > news:Or**************@TK2MSFTNGP11.phx.gbl...
>> >>I am writing mobile application using Vb.net
>> >>
>> >> when i click the last row of list view, and try to delete it....
>> >> will promtpy the following message "Additional information:
>> >> ArgumentOutOfRangeException"
>> >>
>> >> what does that mean ?
>> >>
>> >> I can delete any row without problem but except last row only....
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>>


Nov 21 '05 #9
If I understand you correctly, you have code in the SelectedIndexChanged
event handler that assumes there is always a selected/focused item; if that
is the case simply check if indeed there is a selected item and return if
there isn't, e.g.:

'// in SelectedIndexChangedEvent make this the first line
If (ListView1.SelectedItems.Count = 0) Then Return

Cheers
Daniel
--
http://www.danielmoth.com/Blog/
" A_PK" <pk***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
yes....when there is no record selected, then when i trigger
listview1.focuseditem.text then i will encounter problem....

after i delete my last row record, the system always trigger the event
listview1.selectedindexchanged, under that i got coding like
listiview1.focuseditem.text, so i will have problem

how could i avoid that...

when no record is being selected, then i dun want to trigger that
listview1.focuseditem.text

thank you
"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
After you have deleted your selected row (last row), the index:
listView1.SelectedIndices(0)
Will be set automatically to -1 becasause no record is selected.
"A_PK" wrote:
if listview only got one row, after i have deleted that row, where
should i
set my index ?? and how should i set my index...

thanks you

"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
> If you allow only one item to be selected you can use this line:
> If (ListView1.SelectedItems.Count > 0) Then
> ListView1.SelectedItems(0).Remove()
> End If
>
>
>
> "A_PK" wrote:
>
>>
>> The following is the code that I delete my last row in List VIew
>>
>> -----
>> With ListView1.FocusedItem
>>
>> ListView1.Items.Remove(ListView1.Items(.Index))
>>
>> End With
>> ------
>>
>> How can I set the index to -1 after i delete ?
>> if i only have 1 row in ListView, by adjusting index to -1 will still
>> face
>> the problem since there is no record.
>>
>> Pls guide
>>
>>
>>
>> "Daniel Moth" <dm*****@hotmail.com> wrote in message
>> news:uG****************@TK2MSFTNGP10.phx.gbl...
>> > Show us the code... If you are using the index for deleting you
>> > should
>> > be
>> > adjusting by -1
>> >
>> > Cheers
>> > Daniel
>> > --
>> > http://www.danielmoth.com/Blog/
>> >
>> >
>> > " A_PK" <pk***@hotmail.com> wrote in message
>> > news:Or**************@TK2MSFTNGP11.phx.gbl...
>> >>I am writing mobile application using Vb.net
>> >>
>> >> when i click the last row of list view, and try to delete it....
>> >> will promtpy the following message "Additional information:
>> >> ArgumentOutOfRangeException"
>> >>
>> >> what does that mean ?
>> >>
>> >> I can delete any row without problem but except last row only....
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>>


Nov 21 '05 #10
Then just add this line in the SelectedIndexChanged sub as the first line:
If (listView1.SelectedItems.Count = 0) Then Exit Sub

"A_PK" wrote:
yes....when there is no record selected, then when i trigger
listview1.focuseditem.text then i will encounter problem....

after i delete my last row record, the system always trigger the event
listview1.selectedindexchanged, under that i got coding like
listiview1.focuseditem.text, so i will have problem

how could i avoid that...

when no record is being selected, then i dun want to trigger that
listview1.focuseditem.text

thank you
"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
After you have deleted your selected row (last row), the index:
listView1.SelectedIndices(0)
Will be set automatically to -1 becasause no record is selected.
"A_PK" wrote:
if listview only got one row, after i have deleted that row, where should
i
set my index ?? and how should i set my index...

thanks you

"Alex Levi" <Al******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
> If you allow only one item to be selected you can use this line:
> If (ListView1.SelectedItems.Count > 0) Then
> ListView1.SelectedItems(0).Remove()
> End If
>
>
>
> "A_PK" wrote:
>
>>
>> The following is the code that I delete my last row in List VIew
>>
>> -----
>> With ListView1.FocusedItem
>>
>> ListView1.Items.Remove(ListView1.Items(.Index))
>>
>> End With
>> ------
>>
>> How can I set the index to -1 after i delete ?
>> if i only have 1 row in ListView, by adjusting index to -1 will still
>> face
>> the problem since there is no record.
>>
>> Pls guide
>>
>>
>>
>> "Daniel Moth" <dm*****@hotmail.com> wrote in message
>> news:uG****************@TK2MSFTNGP10.phx.gbl...
>> > Show us the code... If you are using the index for deleting you
>> > should
>> > be
>> > adjusting by -1
>> >
>> > Cheers
>> > Daniel
>> > --
>> > http://www.danielmoth.com/Blog/
>> >
>> >
>> > " A_PK" <pk***@hotmail.com> wrote in message
>> > news:Or**************@TK2MSFTNGP11.phx.gbl...
>> >>I am writing mobile application using Vb.net
>> >>
>> >> when i click the last row of list view, and try to delete it....
>> >> will promtpy the following message "Additional information:
>> >> ArgumentOutOfRangeException"
>> >>
>> >> what does that mean ?
>> >>
>> >> I can delete any row without problem but except last row only....
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>>


Nov 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Adi Tan via .NET 247 | last post by:
Hi All, I had problem with listview, I am able to sort the columns in listview and after doin the sort, if I try to delete a row from ListView its deleting another row. any help is highly...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
2
by: Adam Klobukowski | last post by:
Hello i need to find out the last fully visible item of a Llistview. If it would be a treeview then it would be easy, I'm even thinkin of faking my treeview as listview, but maybe there is some...
0
by: Raphael | last post by:
Hi Everyone, I need some help in Editing and Deleting a record from a listview. Example- I have a list view that is populated from an Access Database, I will like users to click on any record in...
0
by: sonu | last post by:
Hi all, I have a listview control which has four columns like { Col1, Col2, Col3, Col4}. I add data in listview like this, dim lvitem as listviewItem
0
by: inandout | last post by:
Hi, I was wondering if anyone can help me with this. I have a listview that is specified to a size of: 348W x 308H When items are added to it, no problems. However when items continue to be...
0
by: shapper | last post by:
Hello, I created a ListView with a DataPager associated with it. The ListView renders as a table but I suppose it is irrelevant for the problem I describe here. I moved the ListView to a...
1
by: shapper | last post by:
Hello, I have a ListView where I use LINQ for data, for example, selecting, and deleting. In the ListView item template I added a DataPager. When I click, for example, "Next Page" or a page...
2
by: Brad Pears | last post by:
I am working on a new vb.net 2005 project using SQL server 2000 as the backend db. I have a listview where control I want a user to be able to select either just one or multiple rows in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.