473,779 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listview problem

I have a listview (lstvwAmend) (containing 2 columns) that is populated by a filtered dataview (dvRPA) that is based on a dataset (dsRPAmend1) pulling data from a SQL Server database
This dataview will contain 0-10 records.
The dataview is displaying field 1 & field 2 from my dataview
When a user clicks on one of the items in the listview, I want to set the value of a textbox on my form to equal field 3 from the same row in my dataview
I can't seem to make this work

I'm not sure if this is relevant, but pasted below is the code that populates my listbox

lstvwAmend.Data Bindings.Clear(
lstvwAmend.Refr esh(

DsRPAmend1.Clea r(
SqlDA_RPAmend.F ill(DsRPAmend1

dvRPA = New DataVie

With dvRP
.Table = DsRPAmend1.Tabl es("TDT_ROAD_PE RMIT_AMEND"
.RowFilter = "ID_ROAD_PE RMIT = '" & txtRPID.Text & "'
.Sort = "NUM_AMENDM ENT
End Wit

'create listview to display amendment number and associated C
Dim i As Intege

lstvwAmend.Item s.Clear(
lstvwAmend.Refr esh(
For i = 0 To dvRPA.Count -
Dim LVI As New ListViewIte
LVI.Text = dvRPA.Item(i).I tem(3
If IsDBNull(dvRPA. Item(i).Item(5) ) The
Els
LVI.SubItems.Ad d(dvRPA.Item(i) .Item(5)
End I
lstvwAmend.Item s.Add(LVI
Nex

Any suggestions
Thanks
amber
Nov 20 '05 #1
3 2231
Store each item from dvRPA into the Tag property of the
corresponding ListViewItem, i.e. add this to your loop:
LVI.Tag = dvRPA.Item(i)

Then add a handler to the SelectedIndexCh anged event
from the listview and extract the data that you want

/claes

"amber" <an*******@disc ussions.microso ft.com> wrote in message
news:4F******** *************** ***********@mic rosoft.com...
I have a listview (lstvwAmend) (containing 2 columns) that is populated by a filtered dataview (dvRPA) that is based on a dataset (dsRPAmend1) pulling
data from a SQL Server database. This dataview will contain 0-10 records.
The dataview is displaying field 1 & field 2 from my dataview.
When a user clicks on one of the items in the listview, I want to set the value of a textbox on my form to equal field 3 from the same row in my
dataview. I can't seem to make this work.

I'm not sure if this is relevant, but pasted below is the code that populates my listbox:
lstvwAmend.Data Bindings.Clear( )
lstvwAmend.Refr esh()

DsRPAmend1.Clea r()
SqlDA_RPAmend.F ill(DsRPAmend1)

dvRPA = New DataView

With dvRPA
.Table = DsRPAmend1.Tabl es("TDT_ROAD_PE RMIT_AMEND")
.RowFilter = "ID_ROAD_PE RMIT = '" & txtRPID.Text & "'"
.Sort = "NUM_AMENDM ENT"
End With

'create listview to display amendment number and associated CP
Dim i As Integer

lstvwAmend.Item s.Clear()
lstvwAmend.Refr esh()
For i = 0 To dvRPA.Count - 1
Dim LVI As New ListViewItem
LVI.Text = dvRPA.Item(i).I tem(3)
If IsDBNull(dvRPA. Item(i).Item(5) ) Then
Else
LVI.SubItems.Ad d(dvRPA.Item(i) .Item(5))
End If
lstvwAmend.Item s.Add(LVI)
Next

Any suggestions?
Thanks,
amber

Nov 20 '05 #2
Thanks for your help
I'm still doing something wrong
I have added the line
LVI.Tag = dvRPA.Item(i
and left the LVI.Text = dvRPA.Item(i) or else the text wouldn't display
So it all looks good, but the textbox still won't update
My code for the SelectedIndexCh anged event is
Me.txtAmend.Dat aBindings.Clear (
Me.txtAmend.Dat aBindings.Add(" text", dvRPA, "ID_ROAD_PERMIT _AMEND"
my dataview (dvRPA) is declared at the class level

I do this exact same thing with my listboxes, with the exact same code, and it works great, but with my listview,
when the listview item is selected, no matter how many items there are, or which one is selected,
the textbox (txtAmend) is always populated with the item that is associated with the first item in the listview

Any ideas

Thanks
Amber
Nov 20 '05 #3
Do you have to use databinding?

Private Sub OnSelectedIndex Changed()
If myListView.Sele ctedItems.Count = 0 Then
txtAmend.Text = String.Empty
Else
Dim o as myDataType = CType(myListVie w.SelectedItems (0).Tag,
myDataType)
txtAmend.Text = o.Item(3).ToStr ing
End If
End Sub

/claes
"amber" <an*******@disc ussions.microso ft.com> wrote in message
news:99******** *************** ***********@mic rosoft.com...
Thanks for your help.
I'm still doing something wrong.
I have added the line:
LVI.Tag = dvRPA.Item(i)
and left the LVI.Text = dvRPA.Item(i) or else the text wouldn't display.
So it all looks good, but the textbox still won't update.
My code for the SelectedIndexCh anged event is:
Me.txtAmend.Dat aBindings.Clear ()
Me.txtAmend.Dat aBindings.Add(" text", dvRPA, "ID_ROAD_PERMIT _AMEND")
my dataview (dvRPA) is declared at the class level.

I do this exact same thing with my listboxes, with the exact same code, and it works great, but with my listview, when the listview item is selected, no matter how many items there are, or which one is selected, the textbox (txtAmend) is always populated with the item that is associated with the first item in the listview.
Any ideas?

Thanks,
Amber

Nov 20 '05 #4

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

Similar topics

0
1177
by: Steph. | last post by:
I use a ListView in a form to display Data from an SQL db. My problem is that I can fill the listview in less than a second when I show the form AFTER filling the listview, but I take 35 seconds if I show the form BEFORE filling the listview !!! Yes I call ListView's BeginUpdate()/EndUpdate() methods, I tried with hiding the ListView before filling it, I tried Suspend/resume Layout,. nothing works, I still have to wait 35...
15
3898
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows. now use task manager to see the GDI usage of the process. everything seems normal. now catch the ListView's scroller and start to move it downwards. you have to hold the constant speed so that the ListView is constantly repainted. look at the...
0
1425
by: Sérgio Almeida | last post by:
Greetings I have a problem using listview control. Well, I belive that this is not realy a problem, but it's consuming me precious time. Here is the scenario (an example of my problem). I have a SqlServer CE table named students that has 2 fields: students name and grade.
3
9317
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data, checkbox's and icons are displayed as they are meant to be. My problem is this, I am trying to achieve the same results as I get with CheckListBox(s), where I am able to select (Check-mark) various checkboxs items and able to alter the data. I do...
4
3860
by: firefox | last post by:
Hola Foro!, tengo una rutina que permite agregar varios elementos o items de una sola vez en un ListView. Lo que sucede es que en el momento que se añaden los items al ListView se pone todo blanco, cuando se terminan de agregar los items vuelve a su estado normal. Como impido que esto suceda ?. Gracias Mil.
4
10851
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't not want to display this menu if a node selected on the listview but user right click over the empty space of the panel that contain the listview. The problem here is when I use the Listview's Click Event, I don't have ways to verify if the...
3
5409
by: Martin Panggabean | last post by:
Hello All, I've kind a logic problem ... I want to fill the listView control in VB.NET with data in my mySql table using Datareader object component. But It seems that the way of how listView being used is quite different from usual column-row component like Grid component. If you kind a familiar using listView, u must have known what i'm talking about. Here is some example i took from MSDN :...
12
3413
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. Very simple. I would like to create listviewitem's for display in a listview control. The listview items need to contain properties from Internet Explorer windows i've managed to collect into an arraylist.
4
4518
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 is that when clicking on the "Show details" button the ListView for the appropriate row binds in the codebehind and displays the detail data for the selected row. I did something similar with a gridview control previously, but want to be able to...
2
3364
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the 'values' dictionary contains values...." I am using a ListView with a DataSourceID of a LinqDataSource. When a new row icon is clicked....the ListView properly enters into the InsertItemTemplate....however when the ImageButton with a CommandName of...
0
10306
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5373
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.