count start with 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pedro007
    New Member
    • Nov 2009
    • 19

    count start with 1

    hi ,

    how can i start my count in a lisview with 1 .// default is 0.

    listview.items. count=1;// not permissed;

    thanks
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    ListViewItem item = listView.Select edItems[1];

    will give you 1st item from the collection

    This works only if you have more than one items selected in the list.

    then for sub items you can iterate through item

    Regards
    Dheeraj Joshi

    Comment

    • pedro007
      New Member
      • Nov 2009
      • 19

      #3
      hi,

      i want my count start with 1 .

      listview.items. count //start with0

      thnaks

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        I am afraid it is not possible to assign the count to one.

        Regards
        Dheeraj Joshi

        Comment

        • pedro007
          New Member
          • Nov 2009
          • 19

          #5
          i know have you a idea?!

          thanbks

          Comment

          • Dheeraj Joshi
            Recognized Expert Top Contributor
            • Jul 2009
            • 1129

            #6
            BTW, Why you want the count to start by one.?

            Regards
            Dheeraj Joshi
            Last edited by Dheeraj Joshi; Dec 1 '09, 11:37 AM. Reason: Grammer correction

            Comment

            • pedro007
              New Member
              • Nov 2009
              • 19

              #7
              i have a textbox Number ,und this muss be started by one not zero!

              textbox.text=li stview.items.co unt.tostring.//

              how can i make the count start with 1 // listview.items. count=1ยด(Not permissed)

              thanks joschi

              Comment

              • tlhintoq
                Recognized Expert Specialist
                • Mar 2008
                • 3532

                #8
                First: Accept now that all lists and collections are zero-indexed. It is the way the programming languages are constructed. The sooner you stop fighting and start working with it the happier you will be.

                Second: Accept that you may have to manipulate data presentation to make it more "human readable" and less "geek-speak"

                Three: Relax.

                Four: Don't get tunnel vision thinking there is only way way to do something. You are so focused on changing the ListView that you are not thinking about any other way to do what you want.
                i have a textbox Number ,und this muss be started by one not zero!
                Code:
                textbox.text=listview.items.count.tostring
                .//
                The count of items is zero if you have no items. So what you really want is for the text box to show a number 1 greater than your actual count.

                Code:
                textbox.text = (listview.items.count + 1).ToString();

                Comment

                • pedro007
                  New Member
                  • Nov 2009
                  • 19

                  #9
                  hi,

                  thanks tlhintoq.its helped und thank you for the advices .

                  Regards

                  Comment

                  Working...