473,569 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

list view question

See Code:

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim oListView As New ListView
Dim oItem As ListViewItem
Dim cnt As Integer
Dim msg As String
Me.Controls.Add (oListView)
oListView.Dock = DockStyle.Fill
oListView.Colum ns.Add("Line #", 80, HorizontalAlign ment.Right)
oListView.View = View.Details
For cnt = 1 To 100
msg = "LINE #: " & CStr(cnt)
oItem = oListView.Items .Add(msg, 0)
If cnt = 23 Then
oListView.Items (22).Selected = True
oListView.Ensur eVisible(22)
End If
Next
End Sub

How come when I run the code, line 23 is selected (like I want), but if
I hit the down arrow, the selection moves to item 2 and NOT item 24. I
want it to move to item 24.

Can someone PLEASE help me.

Thanks.
Darin

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
3 1306
Hi Darin

Include the following line as well:

oListView.Items (22).Focused = True

HTH

Charles
"Darin" <darin_nospam@n ospamever> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
See Code:

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim oListView As New ListView
Dim oItem As ListViewItem
Dim cnt As Integer
Dim msg As String
Me.Controls.Add (oListView)
oListView.Dock = DockStyle.Fill
oListView.Colum ns.Add("Line #", 80, HorizontalAlign ment.Right)
oListView.View = View.Details
For cnt = 1 To 100
msg = "LINE #: " & CStr(cnt)
oItem = oListView.Items .Add(msg, 0)
If cnt = 23 Then
oListView.Items (22).Selected = True
oListView.Ensur eVisible(22)
End If
Next
End Sub

How come when I run the code, line 23 is selected (like I want), but if
I hit the down arrow, the selection moves to item 2 and NOT item 24. I
want it to move to item 24.

Can someone PLEASE help me.

Thanks.
Darin

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2
If you checkout the selected indices property using your current code
you'll probably find that you have 2 items in the collection.
(Item 0 ) selected by default and item 22 selected by your code. When you
hit the down arrow the underlying UI nav for the list box
chooses the first item as the point of origin and then moves from it to the
next (item 2).

You'd be better off appending these items as an array and using BeginUpdte
& . EndUpdate (much faster and cleaner etc). But in just going with your
flow i'd rewrite like this an see what happens:

With oListView
For cnt = 1 To 100
msg = "LINE #: " & CStr(cnt)
oItem = .Items.Add(msg, 0)
Next

.SelectedItems. Clear
.Items(22).Sele cted = True
.EnsureVisible( 22)
End With

Crap code but it should work.

Richard

I think you'd be better of using the selectedindex property.
"Darin" <darin_nospam@n ospamever> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
See Code:

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim oListView As New ListView
Dim oItem As ListViewItem
Dim cnt As Integer
Dim msg As String
Me.Controls.Add (oListView)
oListView.Dock = DockStyle.Fill
oListView.Colum ns.Add("Line #", 80, HorizontalAlign ment.Right)
oListView.View = View.Details
For cnt = 1 To 100
msg = "LINE #: " & CStr(cnt)
oItem = oListView.Items .Add(msg, 0)
If cnt = 23 Then
oListView.Items (22).Selected = True
oListView.Ensur eVisible(22)
End If
Next
End Sub

How come when I run the code, line 23 is selected (like I want), but if
I hit the down arrow, the selection moves to item 2 and NOT item 24. I
want it to move to item 24.

Can someone PLEASE help me.

Thanks.
Darin

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #3
Thanks -that worked

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #4

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

Similar topics

8
1863
by: Guy Hocking | last post by:
Hi there, I am having a few problems compiling a list box that is conditional on what is selected in another list box. What i need is a List box (lstArea) that displays one thing when the List Box (lstRegion) is selected East or West. Basically the areas will change when East or West is selected in lstRegion. The data comes from an SQL...
5
3612
by: Xah Lee | last post by:
suppose i'm going to have a data structure like this: , , , , .... ] should i use (width,height) or ?
19
13557
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e., head and tail are not connected. Of course, recursive function aproach to traverse the list is one way. But, depending upon the list size, it...
5
2278
by: Praveen R | last post by:
Hi ! I am using a List view control to populate data onto. On the click event of the list view control, i need to find out whether the area clicked has any information of has no information. I basically need to either decide to add a new record or edit the existing record depending on whether data is available or not on the row where the...
0
3221
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another way... here is my code on how I did it to help anyone starting out get an idea of how to use virtual mode in ..NET 2.0 Imports...
90
10738
by: Christoph Zwerschke | last post by:
Ok, the answer is easy: For historical reasons - built-in sets exist only since Python 2.4. Anyway, I was thinking about whether it would be possible and desirable to change the old behavior in future Python versions and let dict.keys() and dict.values() both return sets instead of lists. If d is a dict, code like: for x in d.keys():
15
25782
by: Andrew Brampton | last post by:
Hi, This may sound a odd question, but I wanted to know how you return a list of data from a function. These are some of the ways I know how, and I was wondering which method you normally use. This is more of a best practices question rather than a technical one. 1) Return a list instance ie std::list myFunction() { std::list list();...
2
1706
by: Kaur | last post by:
Hi, I have a form Form1 that displays surveys. This form has a subform1 which displays questions related to a particular survey. This subform has a subsubform which displays subquestions for a particular question for a particular survey. I have created a combo box for questions on subform1. What I am trying to achieve is if a user wants to...
0
1141
by: anna_parkins7 | last post by:
Hi Quick question, that will point me in the right direction. I have 2 user controls on a page, both called List.ascx but obviously in 2 different namespaces and 2 different tags.. however I get the error: Compiler Error Message: CS1595: 'ASP.List_ascx' is defined in multiple places; using definition from...
1
1494
by: Jeff Williams | last post by:
With a list view is it possible and if so how to turn off the search function. What I mean is if you are in a list view and start typing it will search the first column to match or close match a value in the first column like auto complete. I dont need this to happen. if column 1 contains a series of numbers from 1 to 500. If you enter...
0
7926
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
8138
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...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
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
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
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.