locked
listview in mobile 6 RRS feed

  • Question

  • HI,

    I 've searched the net on many sites but still can not find what I need. After the data in the listview how can I get a value for it .

    In almost all sites i saw listview1.selectitems(0).subitems(2).text but this don't work in CF. There i can find listview1.selectindices but the only thing i can select is the item index

    so how can i get a subitem from item in listview?


    TcoUpLoad (Vb6 and VbNet | starting learning C#)
    Wednesday, February 9, 2011 4:37 PM

All replies

  • a good example to follow....

    http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.selectedindices.aspx
    TcoUpLoad (Vb6 and VbNet | starting learning C#)
    Wednesday, February 9, 2011 6:57 PM
  •  

    Hi Tcomsn,

     

    I just found out this problem, but please pay attention to the index of the SubItems should begin with 1 not 0, in your codes, you should use it like "this.listView1.Items[0].SubItems[1].Text" and it works fine.

     

    Please check the Note segment in ListViewItem.SubItems Property

     

    I hope my suggestion can help you to solve this problem.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jesse Jiang Tuesday, February 15, 2011 9:02 AM
    • Unmarked as answer by Tcomsn Tuesday, March 22, 2011 6:47 PM
    Friday, February 11, 2011 7:23 AM
  • Hi Jesse, but that is not my doubts. My doubt is how to retrieve the data from the listview in compact framework because the compact framework does not contain the SelectedItems in listview component

    As for the index of the subitem I can choose anyone since it is in the listview


    TcoUpLoad (Vb6 and VbNet | starting learning C#)
    Tuesday, March 22, 2011 6:55 PM
  • Hi Tocmsn,

     

    I am not sure what is your requirement however If you are looking for how to retrieve data from the list view control then you have to use below code snippet for the same.

     

     

    for (int i = 0; i < ListView1.Items.Count; i++)
     {
      string strData = ListView1.Items[i].Text
     }
    

     

     

    Hope it helps.


    - Pavan [MCTS - Windows Mobile 5.0] If you find my post is helpful for you then mark as a answer and vote it.
    Wednesday, March 23, 2011 4:17 AM
  • hi WmDev,

    isn't that i want.

    1st your code works in a stange way... runs all items of listview and only keep the last value.

    2nd where you catch de subitems values?

    3th if your listview have 10 items how you catch item 5 value and their subitems?

    i need a code that runs in windows mobile / compact framework so i can awnser that 3 questions.


    TcoUpLoad (Vb6 and VbNet | starting learning C#)
    Friday, March 25, 2011 1:24 PM