473,550 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox scroll

Hello.

/windows forms/
I'm marking listbox items as selected, and I'd like to scroll listbox to
a selected entry if it is off-screen. How can I do it?

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl
Nov 16 '05 #1
6 11527
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@nemesis.news .tpi.pl:
Hello.

/windows forms/
I'm marking listbox items as selected, and I'd like to scroll
listbox to a selected entry if it is off-screen. How can I do
it?


Adam,

Setting ListBox.Selecte dIndex should automatically scroll the listbox
to the selected item.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2
Chris R. Timmons napisał(a):
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@nemesis.news .tpi.pl:

Hello.

/windows forms/
I'm marking listbox items as selected, and I'd like to scroll
listbox to a selected entry if it is off-screen. How can I do
it?

Adam,

Setting ListBox.Selecte dIndex should automatically scroll the listbox
to the selected item.


Ok, but ListBox.Selecte dIndex is read only. Should I use property or
method of it? If yes, which one?

I tried something like this:
s_lv.Items[ret].Selected = true;
rozlacz.Enabled = true;
s_lv.SelectedIt ems[ret].Selected =true;

But it doesn't work :(

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl
Nov 16 '05 #3
Adam Klobukowski napisał(a):
Chris R. Timmons napisał(a):
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@nemesis.news .tpi.pl:
Hello.

/windows forms/
I'm marking listbox items as selected, and I'd like to scroll
listbox to a selected entry if it is off-screen. How can I do
it?


Adam,

Setting ListBox.Selecte dIndex should automatically scroll the listbox
to the selected item.

Ok, but ListBox.Selecte dIndex is read only. Should I use property or
method of it? If yes, which one?

I tried something like this:
s_lv.Items[ret].Selected = true;
rozlacz.Enabled = true;
s_lv.SelectedIt ems[ret].Selected =true;

But it doesn't work :(


Damn I made mess ;)

It should be:

s_lv.Items[ret].Selected = true;
s_lv.SelectedIt ems[0].Selected =true;

And it is not a lisbox but listview and it has multiselect=fal se property.

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl
Nov 16 '05 #4
ListBox.Selecte dIndex is read/write, so just set it to the zero based index
you want to be selected in the listbox.

s_lv.SelectedIn dex = 3;

--Liam.

"Adam Klobukowski" <at***@gabo.p l> wrote in message
news:cn******** **@atlantis.new s.tpi.pl...
Chris R. Timmons napisał(a):
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@nemesis.news .tpi.pl:

Hello.

/windows forms/
I'm marking listbox items as selected, and I'd like to scroll
listbox to a selected entry if it is off-screen. How can I do
it?

Adam,

Setting ListBox.Selecte dIndex should automatically scroll the listbox
to the selected item.


Ok, but ListBox.Selecte dIndex is read only. Should I use property or
method of it? If yes, which one?

I tried something like this:
s_lv.Items[ret].Selected = true;
rozlacz.Enabled = true;
s_lv.SelectedIt ems[ret].Selected =true;

But it doesn't work :(

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl

Nov 16 '05 #5
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@atlantis.new s.tpi.pl:
Adam Klobukowski napisał(a):
Chris R. Timmons napisał(a):
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@nemesis.news .tpi.pl:

Hello.

/windows forms/
I'm marking listbox items as selected, and I'd like to scroll
listbox to a selected entry if it is off-screen. How can I do
it?

Adam,

Setting ListBox.Selecte dIndex should automatically scroll the
listbox to the selected item.

Ok, but ListBox.Selecte dIndex is read only. Should I use
property or method of it? If yes, which one?

I tried something like this:
s_lv.Items[ret].Selected = true;
rozlacz.Enabled = true;
s_lv.SelectedIt ems[ret].Selected =true;

But it doesn't work :(


Damn I made mess ;)

It should be:

s_lv.Items[ret].Selected = true;
s_lv.SelectedIt ems[0].Selected =true;

And it is not a lisbox but listview and it has multiselect=fal se
property.


Adam,

Try this:

this.listView1. Select();
this.listView1. Items[ret].Selected = true;
this.listView1. EnsureVisible(r et);

The ListView has to be selected before it will honor a request to
programmaticall y select an item (I don't know why...).

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #6
Chris R. Timmons napisał(a):
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn******** **@atlantis.new s.tpi.pl:

Adam Klobukowski napisał(a):
Chris R. Timmons napisał(a):
Adam Klobukowski <at***@gabo.p l> wrote in
news:cn**** ******@nemesis. news.tpi.pl:
>Hello.
>
>/windows forms/
>I'm marking listbox items as selected, and I'd like to scroll
>listbox to a selected entry if it is off-screen. How can I do
>it?

Adam,

Setting ListBox.Selecte dIndex should automatically scroll the
listbox to the selected item.
Ok, but ListBox.Selecte dIndex is read only. Should I use
property or method of it? If yes, which one?

I tried something like this:
s_lv.Items[ret].Selected = true;
rozlacz.Enab led = true;
s_lv.Selecte dItems[ret].Selected =true;

But it doesn't work :(


Damn I made mess ;)

It should be:

s_lv.Items[ret].Selected = true;
s_lv.Selected Items[0].Selected =true;

And it is not a lisbox but listview and it has multiselect=fal se
property.

Adam,

Try this:

this.listView1. Select();
this.listView1. Items[ret].Selected = true;
this.listView1. EnsureVisible(r et);

The ListView has to be selected before it will honor a request to
programmaticall y select an item (I don't know why...).


It works, thanks.

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
42691
by: Filips Benoit | last post by:
Dear All, I have code that selects - find and select - 1 item in a large listbox. This works Ok but most of the time the selected item isn't visible without scrolling down manualy. Is this possible by code? Filip
4
3211
by: deko | last post by:
I have an Access 2003 mdb with a Main Form that has a ListBox with a long list of items. The problem is the scroll bar on the ListBox does not scroll all the way to the end unless you first scroll half way, then let up the left mouse button, and then continue to scroll to the end of the list. But once you've scrolled the entire list once,...
1
6863
by: Keltus | last post by:
Hello, I have a Form with a ListBox in it. I'd like to be able to scroll the ListBox even when it's not in focus. ie. when i scroll the mousewheel when my focus is on the form, I'd like the ListBox to scroll. Now, there are two ways I would think would work. The first is if I can resend the MouseEventArgs to the ListBox but there does not...
1
9855
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't work. Thanks ahead.
2
8912
by: John | last post by:
Hi, I'm currently working on a simple project (for study on C#) with an input (maskedtextbox) and a listbox. The input numbers are send in the listbox. When the listbox is filled with numbers it automaticly puts the scrollbar in the listbox, thats fine but it doesn't scroll down to the last number that was keyed in and isn't visible. You...
3
14415
by: superjacent | last post by:
Hope someone can help. I have a listbox displaying time periods in blocks of 15 mins for a 24 hour period, all up 96 rows. The listbox can only visibly show 20 rows a time. The default feature is that the first row is at the top of the listbox.
0
1608
by: R.Nijkamp | last post by:
Hello, i was wondering if its an limitation of IE when a asp.net listbox is set disabled, then a user wont be able to scroll inside the listbox. While the user can scroll inside the listbox when he uses firefox. Below a simple code which i tested: <form id="Form1" runat="server"> <asp:ListBox id="drop1" rows="3" runat="server" disabled>
7
5584
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client browser the list box scroll position is at the top.
5
17729
by: WRH | last post by:
Hello I want to have a multicolumn listbox. I never used one before so I looked at a Help example. I set the multicolumn property and the column width and tested with this example... this.listBox3.Items.AddRange(new object { "Item 1, column 1", "Item 2, column 1", "Item 3, column 1",
0
7561
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7488
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7999
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7520
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3532
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3517
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1094
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.