Listview question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kay

    #1

    Listview question

    Hi all,

    I know that I can get the value of a particualar column in a list view by
    something like this:
    lvwRoster.Selec tedItems(0).Sub Items(2).Text

    However, is it possible to get the value by column name? In vb.net you can
    assign a column name for each column, but I don't know where I can use
    it.... any idea?

    Thx~~~

    Kay


  • Cor Ligthert [MVP]

    #2
    Re: Listview question

    Kay,

    A listview is not a datatable (dataview).
    A listview has headers but AFAIK no column names,

    Cor

    "Kay" <kk@kk.com.kksc hreef in bericht
    news:eH3wUuZxGH A.3788@TK2MSFTN GP02.phx.gbl...
    Hi all,
    >
    I know that I can get the value of a particualar column in a list view by
    something like this:
    lvwRoster.Selec tedItems(0).Sub Items(2).Text
    >
    However, is it possible to get the value by column name? In vb.net you
    can assign a column name for each column, but I don't know where I can use
    it.... any idea?
    >
    Thx~~~
    >
    Kay
    >

    Comment

    • Kay

      #3
      Re: Listview question

      It has Cor...in a listview's property, it has a "columns" collection, in
      each column you can assign a name there, it also where you can assign the
      column Text.... am I correct?

      Kay


      "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
      news:eXPUXgaxGH A.4968@TK2MSFTN GP03.phx.gbl...
      Kay,
      >
      A listview is not a datatable (dataview).
      A listview has headers but AFAIK no column names,
      >
      Cor
      >
      "Kay" <kk@kk.com.kksc hreef in bericht
      news:eH3wUuZxGH A.3788@TK2MSFTN GP02.phx.gbl...
      >Hi all,
      >>
      >I know that I can get the value of a particualar column in a list view by
      >something like this:
      >lvwRoster.Sele ctedItems(0).Su bItems(2).Text
      >>
      >However, is it possible to get the value by column name? In vb.net you
      >can assign a column name for each column, but I don't know where I can
      >use it.... any idea?
      >>
      >Thx~~~
      >>
      >Kay
      >>
      >
      >

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Listview question

        Kay,

        But AFAIK does by instance a datatable column describe a datarow item.
        (Therefore you cannot simple move a datarow to another datatable).

        A listview column describes only a header column not a
        listviewitemcol lection item.

        Cor

        "Kay" <kk@kk.com.kksc hreef in bericht
        news:ej0%230Abx GHA.5064@TK2MSF TNGP04.phx.gbl. ..
        It has Cor...in a listview's property, it has a "columns" collection, in
        each column you can assign a name there, it also where you can assign the
        column Text.... am I correct?
        >
        Kay
        >
        >
        "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
        news:eXPUXgaxGH A.4968@TK2MSFTN GP03.phx.gbl...
        >Kay,
        >>
        >A listview is not a datatable (dataview).
        >A listview has headers but AFAIK no column names,
        >>
        >Cor
        >>
        >"Kay" <kk@kk.com.kksc hreef in bericht
        >news:eH3wUuZxG HA.3788@TK2MSFT NGP02.phx.gbl.. .
        >>Hi all,
        >>>
        >>I know that I can get the value of a particualar column in a list view
        >>by something like this:
        >>lvwRoster.Sel ectedItems(0).S ubItems(2).Text
        >>>
        >>However, is it possible to get the value by column name? In vb.net you
        >>can assign a column name for each column, but I don't know where I can
        >>use it.... any idea?
        >>>
        >>Thx~~~
        >>>
        >>Kay
        >>>
        >>
        >>
        >
        >

        Comment

        • gene kelley

          #5
          Re: Listview question

          On Tue, 22 Aug 2006 13:34:58 +1000, "Kay" <kk@kk.com.kkwr ote:
          >Hi all,
          >
          >I know that I can get the value of a particualar column in a list view by
          >something like this:
          >lvwRoster.Sele ctedItems(0).Su bItems(2).Text
          >
          >However, is it possible to get the value by column name? In vb.net you can
          >assign a column name for each column, but I don't know where I can use
          >it.... any idea?
          >
          >Thx~~~
          >
          >Kay
          >
          The DataGridView control, unbound, can be configured to look indentical to a ListView, Detail View,
          and will give you the functionality you are looking for.

          Gene

          Comment

          • Al Reid

            #6
            Re: Listview question

            Kay wrote:
            Hi all,
            >
            I know that I can get the value of a particualar column in a list
            view by something like this:
            lvwRoster.Selec tedItems(0).Sub Items(2).Text
            >
            However, is it possible to get the value by column name? In vb.net
            you can assign a column name for each column, but I don't know where
            I can use it.... any idea?
            >
            Thx~~~
            >
            Kay
            Kay,

            If you set the Name property on the ListViewItem and the ListViewSubItem s as you add them into the ListView you can then access the
            columns by name. For example, if you set the ListViewItem.Na me to "FirstName" then you can access the column as:

            lvwRoster.Selec tedItems(0).Sub Items("FirstNam e").Text

            I hope this helps.

            --
            Al Reid


            Comment

            Working...