Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Problem with Listview Controls in VB.NET

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 28-01-2010
Member
 
Join Date: Dec 2009
Posts: 73
Problem with Listview Controls in VB.NET
  

Hello everyone i am very much new to VB.Net programming language. I am having a problem with the listview control in VB.NET. Actually i want to add a certain value at a certain location for a listview in VB.net. For example consider adding a new row at the currently selected area. The program which i have does the addition of new rows but at the location '0' . Kindly give a suitable solution.

Reply With Quote
  #2  
Old 28-01-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: Problem with Listview Controls in VB.NET

It will be better to implement a solution to your problem if you provide some more information on this problem. Be more clear , What you actually mean by saying new row at the currently selected area. Please try to present a clear picture of your problem. As far as i am aware of the VB.NET the Listview object adds a row at the bottom instead of adding a row at the location 0.
Reply With Quote
  #3  
Old 28-01-2010
Member
 
Join Date: May 2008
Posts: 2,381
Re: Problem with Listview Controls in VB.NET

Assuming that you want to add a row below or above a single or a set of items or a multiple rows at a time. you can take the following approach to achieve it.

for inserting a row below a selected row. You will have to make use of the method SelectedIndices() under the list view class which will return an array containing the Index of the selected items in the list. The index of the first item is 0.

and your code will somewhat look like

Dim Max as Integer = lsvname.SelectedIndices.Item (0)
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 28-01-2010
Member
 
Join Date: Dec 2009
Posts: 73
Re: Problem with Listview Controls in VB.NET

Thanks for the replies As one of you have asked to some more detail regarding the problem so i will be providing it. Also the solution implemented by opaper was really a good initiative but that too could give me the desired output. So i am expecting some other solution. Lets me make the problem somewhat more clearer the main objective of the listview is to display data to the screen which is fetch from a mySQL database.

Hear is a part of code

Code:
       lsv1 = uiListViewSData.Items(0)
       indx = uiListViewSData.SelectedItems(0).Index

       uiListViewSData.Items().Insert((indx + 1), "")
Reply With Quote
  #5  
Old 28-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Re: Problem with Listview Controls in VB.NET

I will suggest another approach to achieve this you can get the selected row by simply looking it's index in the SelectedIndices() array's position ZERO. why are you very much sure that this item will be in position ZERO is. Since this array will contain only one item because you are keeping multiselect FALSE. Use the code mentioned below.

Code:
 Dim Max As Integer = lsvReceipts.SelectedIndices.Item(0)
 For Counter = 0 To lsvReceipts.SelectedIndices.Count - 1
If Max < lsvReceipts.SelectedIndices.Item(Counter) Then
Max = lsvReceipts.SelectedIndices.Item(Counter)
   End If

Last edited by MindSpace : 28-01-2010 at 06:25 PM.
Reply With Quote
  #6  
Old 28-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Problem with Listview Controls in VB.NET

It seems as your Listview requires another insert function inorder to add a new row within the listview and at the desired location where the user clicks and move the rows displayed 1 line below down by 1 row.

Following is the code please refer it.

Lstv = uiListViewSData.Items(0)
indx = uiListViewSData.SelectedItems(0).Index

uiListViewSData.Items().Insert((indx + 1), "")
Reply With Quote
  #7  
Old 08-10-2011
RumeshChanchal
 
Posts: n/a
ThumbsUp Re: Problem with Listview Controls in VB.NET

Hey Guys,
Here is simplest one article on ListView control in vb.net, for more information please visit this the following url....

http://mindstick.com/Articles/5924b8...%20in%20VB.Net

Thanks !!!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem with Listview Controls in VB.NET"
Thread Thread Starter Forum Replies Last Post
Alice Madness Returns Controls Problem ROcHANn Video Games 5 21-06-2011 11:49 AM
Killzone 2 delay in the controls problem Ransom Video Games 5 31-03-2010 01:14 AM
Problem with inherits listview in a class component Abdullah30 Software Development 3 28-10-2009 11:54 PM
Problem with Javascript and Activex Controls ? Anathakrishnan Technology & Internet 5 18-02-2009 12:36 PM
limits on listview Christopher Software Development 3 17-10-2008 03:07 PM


All times are GMT +5.5. The time now is 01:47 PM.