473,789 Members | 2,860 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 2232
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
1178
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
3900
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
1426
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
9319
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
3861
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
10852
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
5410
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
3414
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
4519
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
3365
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
10410
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
10200
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...
0
9984
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
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
3
2909
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.