Results 1 to 7 of 7

Thread: Problem with Listview Controls in VB.NET

  1. #1
    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.

  2. #2
    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,393

    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)

  4. #4
    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), "")

  5. #5
    Join Date
    Feb 2008
    Posts
    1,856

    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.

  6. #6
    Join Date
    Oct 2005
    Posts
    2,394

    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), "")

  7. #7
    RumeshChanchal Guest

    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 !!!

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •