473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Selectedindices in Listview navigation..?

Hi groups,I've placed a listview control and four buttons two navigate
inside the list view. Let say

[ button name as First(<<), Pre(<), next(>), Last(>>)].

I have written code for <<, >> :)..even for <,> also..but i'm getting error
in condition.

I mean, if my selected item is the last one, but still if i press >, it
should be at the last item only.

(1) how to limit my navigation when they press (button > ) when they are in
last record..?

(2) Same way, when they are in first record and trying to press
button(<)...i should say that you are in first record..?

please someone suggest to overcome this probs//?
Nov 17 '05 #1
3 5534
Hello
(1) how to limit my navigation when they press (button > ) when they are
in
last record..? You can compare ListView.FocusedItem.Index and ListView.Items.Count. If
current index is equal to (count-1), then not allow to go to next record.
(2) Same way, when they are in first record and trying to press
button(<)...i should say that you are in first record..?

The same. Just compare ListView.FocusedItem.Index with zero.

--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072
Nov 17 '05 #2
Thankz andrew, I tried with focussed item but still its giving error only.

This code is for moving ( > ).

if (lvw.FocusedItem.Index < lvw.Items.Count)

{

lvw.Items[lvw.SelectedIndices[0] + 1].Selected = true;

lvw.Items[lvw.SelectedIndices[0] + 1].ForeColor = Color.Red;

}
"Andrew Kirillov" <an*************@gmail.com> wrote in message
news:Ow**************@TK2MSFTNGP14.phx.gbl...
Hello
(1) how to limit my navigation when they press (button > ) when they are
in
last record..?

You can compare ListView.FocusedItem.Index and ListView.Items.Count. If
current index is equal to (count-1), then not allow to go to next record.
(2) Same way, when they are in first record and trying to press
button(<)...i should say that you are in first record..?

The same. Just compare ListView.FocusedItem.Index with zero.

--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072

Nov 17 '05 #3
No, no. Focused item does not mean selected. You need to define what are you
doing: focusing or selecting.

If selecting, then you need to compare selected item's index with total
count. Something like this
if (lvw.SelectedIndices[0] < lvw.Items.Count - 1)

But, be sure that your countrol is set to single selection mode.

--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072
"¿ Mahesh Kumar" <cy**********@gmail.com> wrote in message
news:e2**************@TK2MSFTNGP12.phx.gbl...
Thankz andrew, I tried with focussed item but still its giving error only.

This code is for moving ( > ).

if (lvw.FocusedItem.Index < lvw.Items.Count)

{

lvw.Items[lvw.SelectedIndices[0] + 1].Selected = true;

lvw.Items[lvw.SelectedIndices[0] + 1].ForeColor = Color.Red;

}
"Andrew Kirillov" <an*************@gmail.com> wrote in message
news:Ow**************@TK2MSFTNGP14.phx.gbl...
Hello
> (1) how to limit my navigation when they press (button > ) when they
> are
> in
> last record..?

You can compare ListView.FocusedItem.Index and ListView.Items.Count. If
current index is equal to (count-1), then not allow to go to next record.
> (2) Same way, when they are in first record and trying to press
> button(<)...i should say that you are in first record..?

The same. Just compare ListView.FocusedItem.Index with zero.

--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072


Nov 17 '05 #4

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

Similar topics

6
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
0
by: rdi | last post by:
the LV's multSelect prop is set to FALSE the LV currently contains 2 items. When I run it through the debugger I watch the SELECTEDINDICES property of the LV. When I select the first item...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
2
by: stacy | last post by:
I am attempting to port an application from a Windows app to an ASP.NET Web App. I notice that the TreeView and ListView controls are not part of the tool box on the WebForm. Can someone tell me...
1
by: cliopia | last post by:
Hello, I am trying to create a detailed ListView and was wondering if the following was possible and or/ easily implemented in .Net 2.0 / VS2005 standard controls a) Have icons instead of...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
0
by: =?Utf-8?B?SWdvcg==?= | last post by:
Hi everyone! I have some strange behavior of ListView control in WPF. We are developing application in C#. I created ListView with some items and set SelectedIndex to some index in the...
4
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.