Visual Basic 2015 Tutorials: ListView
Recently I worked on a Personal Information Management Software for a client and had to read the value from the last item in ListView control. Of course I haven't any problems by doing that but I knew that many beginners will have a problem with this simple task.I have a database where I insert a unique index in a database field. The most easiest way is to make it as a numbers such 1,2,3,4 etc. But what if I have 20 items and I delete 16 field. Then if you simply calculate it with ListView1.Items.Count + 1 will produce a mistake.
Here it is how I solved this problem.
Visual Basic 2015 Tutorials: Read the the value from the last entry in ListView control
Dim myindex As Integer
myindex = ListView1.Items.Item(ListView1.Items.Count - 1).Text
txtMyIndex.Text = myindex + 1
I hope you find this code useful. If any questions feel free to write in the contact form.
No comments:
Post a Comment