listview vs listbox?

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

    #1

    listview vs listbox?


    In ListBox, I can use SelectedIndex to set for current selected item.
    for(int x = 0; x <25; x++)
    listBox1.Items. Add(x.ToString( ));

    listBox1.Select edIndex = 10;

    How to do the same for ListView?

  • Michael Nemtsev

    #2
    RE: listview vs listbox?

    See there: http://www.syncfusion.com/FAQ/Window...90c.aspx#q797q

    "ttan" wrote:
    [color=blue]
    >
    > In ListBox, I can use SelectedIndex to set for current selected item.
    > for(int x = 0; x <25; x++)
    > listBox1.Items. Add(x.ToString( ));
    >
    > listBox1.Select edIndex = 10;
    >
    > How to do the same for ListView?[/color]

    --
    WBR,
    Michael Nemtsev :: blog: http://spaces.msn.com/laflour

    "At times one remains faithful to a cause only because its opponents do not
    cease to be insipid." (c) Friedrich Nietzsche

    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: listview vs listbox?

      Hi,


      "ttan" <ttan@discussio ns.microsoft.co m> wrote in message
      news:B0E8681B-F88C-42FD-AA9E-3B24D0DC82FE@mi crosoft.com...[color=blue]
      >
      > In ListBox, I can use SelectedIndex to set for current selected item.
      > for(int x = 0; x <25; x++)
      > listBox1.Items. Add(x.ToString( ));
      >
      > listBox1.Select edIndex = 10;
      >
      > How to do the same for ListView?
      >[/color]

      You use ListViewItemIte m.Selected , so the code should be:

      listview1.Items[ 10].Selected = true;


      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation


      Comment

      • ttan

        #4
        Re: listview vs listbox?


        When I use the code you provided, but how come the scroll bar of listview is
        not at the position of the selected item. Inlist box when I do selectedIndex
        the scroll bar is at the selected position.

        Did I missing something?

        "Ignacio Machin ( .NET/ C# MVP )" wrote:
        [color=blue]
        > Hi,
        >
        >
        > "ttan" <ttan@discussio ns.microsoft.co m> wrote in message
        > news:B0E8681B-F88C-42FD-AA9E-3B24D0DC82FE@mi crosoft.com...[color=green]
        > >
        > > In ListBox, I can use SelectedIndex to set for current selected item.
        > > for(int x = 0; x <25; x++)
        > > listBox1.Items. Add(x.ToString( ));
        > >
        > > listBox1.Select edIndex = 10;
        > >
        > > How to do the same for ListView?
        > >[/color]
        >
        > You use ListViewItemIte m.Selected , so the code should be:
        >
        > listview1.Items[ 10].Selected = true;
        >
        >
        > --
        > Ignacio Machin,
        > ignacio.machin AT dot.state.fl.us
        > Florida Department Of Transportation
        >
        >
        >[/color]

        Comment

        Working...