"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]
"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
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