ListView Show Selecteditem
ListView1.SelectedItem.EnsureVisible will scroll the listview until the selected item is visible. But, what if I have multiselect enabled and I have like 10 selected items from 100 in the listview? With each command button click, I need to display next selected item in the list. Of course, I can create a global value and check which selected item was already shown, and just play it of from there, but is there an easier way? Thanks.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listview - Selecteditem
how to replace the value of selected item in listview?
i hv this column header and value
SEL___SQ___ PR___PRSQ
_S_____1____1732____1
i want to replace the value of "S" in SEL column to "D"
i use this
lvwList.SelectedItem.SubItems(1) = "D"
but each time it will replace the data in the "SQ" column
i try to replace the index from "1" to "0" but invalid.
any idea?
Listview Selecteditem
Other than using a For Loop to find out if there is a selected row in a listview:
Code:
If lvReport.ListItems.count > 0 Then
Dim lst As ListItem, i As Integer
For i = 1 To lvReport.ListItems.count
Set lst = lvReport.ListItems(i)
If lst.Selected = True Then
lst.Selected = False
Set lvReport.SelectedItem = Nothing
End If
Next i
End If
Is there a quicker way than this?
ListView.selectedItem
When using the code to for a user to select a row of data from a listview to be removed. I do not get the required results. Once the user has selected a row, it should search the listview for the selected row, find it, then search the recordset for match, then delete the record from recordset and listview.
Code:
If Not LVProf(listviewNo).SelectedItem Is Nothing Then
For i = 1 To LVProf(listviewNo).ListItems.Count
If LVProf(listviewNo).ListItems(i).Text = LVProf(listviewNo).SelectedItem Then
With Myrecordset(listviewNo + 1)
.MoveFirst
While Not .EOF
MsgBox (LVProf(listviewNo).ListItems(i).Text & " " & LVProf(listviewNo).ListItems(i).SubItems(1))
If LVProf(listviewNo).ListItems(i).Text = LVProf(listviewNo).SelectedItem And LVProf(listviewNo).ListItems(i).Text = .Fields(0) And LVProf(listviewNo).ListItems(i).SubItems(1) = .Fields(1) Then
.Delete
Exit For
End If
.MoveNext
Wend
End With
LVProf(listviewNo).ListItems.Remove (i)
End If
Next i
Else
MsgBox ("You have not selected a record to remove")
End If
When I select the last record on the listview control, the line of code (If LVProf(listviewNo).ListItems(i).Text = LVProf(listviewNo).SelectedItem Then
) always picks out the first record in the listview. Why would this be?
ListView.SelectedItem
Put the code in the keyup event, not the key down. When the key is down the previous selected item in the listview will still have focus. Only after the key is up does the newly highlighted item come into reference.
Hope this helps!
ListView.Selecteditem
Is there a way to simulate a selection (let's say to the third item on the
list) and cause the highlight to appear?
Any ideas welcomed and appreciated. Thanks!
Listview SelectedItem Question
I have an array of ListView boxes on a form. I want to know if the user clicks in one of the ListView boxes where there is no Text. This does not work. Anyone have the answer?
Code:
If Jantxt(xx).SelectedItem.Text = "" Then
Form4.Show
End If
SelectedItem.Bold Listview
Hi,
Im trying to set the font of a selected item to normal when unselected. I hope you understand what I'm trying to say.
In the Click_Event of the Listview I wrote:
Code:
Select Case Listview1.selectedItem
Case "blablabla"
Listview2.font.bold = false
listview2.selectedItem.bold = True
Case "blabla"
Listview2.font.bold = false
Listview2.selectedItem.bold = true
...............
Nothing is happening except for becoming bold when selected.
Someone with some experience with this feature?
Thanks in advance.
(by the way: the vbcode tags don't work anymore)
***RESOLVED***ListView SelectedItem
I have a ListView containing two records (rows). My ListView is populated with a main item in the first column and ListSubItems in the adjacent columns.
If the user selects a member of the ListView and clicks a button, I would like a message box to appear stating the contents of the ListView main item for the specific record currently selected.
I know how to do this for ListSubItems:
MsgBox ListView1.SelectedItem.ListSubItems(1)
I just need to know how to do this for the main item now.
thx
Listview SelectedItem Highlight
I got a listview with various other controls on a form.
After I lose focus on the listview, I want to keep whatever was selected Highlighted, not sure how to do this
Listview Problem; Listview.selecteditem
So, I have a listview that displays a series of things, and refreshes every 10 seconds. (By refresh, I mean it clears itself and re-fills all info from a database)
When it refreshes, I want to check and see if any message was selected before the refresh, and if so, select it again.
Code:
'select nothing...GRRRRrr
For i = 1 To frmQuickCom.lstMessages.ListItems.Count
frmQuickCom.lstMessages.ListItems(i).Selected = False
Next
'Reselect the originally selected item
'if there are
Select Case SelText 'this is passed in when this sub is called'
Case ""
'if there are no messages, don't select any
If frmQuickCom.lstMessages.ListItems.Count > 0 Then
frmQuickCom.lstMessages.SelectedItem.Selected = False
End If
Case Else 'something was selected
For i = 1 To frmQuickCom.lstMessages.ListItems.Count
If SelText = frmQuickCom.lstMessages.ListItems(i).Text Then
Set frmQuickCom.lstMessages.SelectedItem = _
frmQuickCom.lstMessages.ListItems(i)
frmQuickCom.rtfMessage.Text = strMsgTransfer
frmQuickCom.lstMessages.SelectedItem.EnsureVisible
End If
Next
'move the window to show the selected item
End Select
So here's the problem -- even if I set selecteditem.selected = false, Selecteditem still has a value. Is there anyway to actually clear that value entirely? (The reason why I ask -- if a message is deleted, it is leaving the last added item (in the next refresh) as the 'selected' item, even though it gets set to false. If I try to key off of the selecteditem value, then, it returns something.)
Change Listview.selecteditem Thru Code?
I have a popupmenu on my listview, and that only fires when a person right clicks. I want it so that if the user right clicks it will still highlight the line they clicked on...possible?
ListView, Removing Listiem Highlighting When SelectedItem Is Nothing
Ok, you have a listview with some rows...
If you have FullRowSelect = True and HideSelection = False then when you select a row, it gets highlighted. We can all see this.
Now, if I use:
VB Code:
Set ListView1.SelectedItem = Nothing
Then no item is selected, BUT the row that was previously highlighted stays highlighted!
Any ideas?
Woka
Here's the prject I am working on.
It's only supposed to be for screen shots at the moment, so my code is a tad rough and not 100% structured yet I appologise.
basically when you click on a GREY CD image I want the listview to DE-select the row...any ideas?
Show Last Item In Listview
Hello!
I'm using a listview in Excel Form. I'm add some itens manual (users entrys), but when the space defined to the listview ends the add item don't show in listview. The user must have to scroll the listview to see the add item.
It's possible to make automatic scroll of the listview to show the last add item ?
I can make this in the listbox, <userform.listbox1.ListIndex =userform.ListBox1.ListCount - 1 > but I can't make in the listview, because the propertys are diferent. I already try, but I can't do it
Thanks for the Help...
Listview Show Id Fields 1,10,11,12,.... Help
In my listview show id field is 1,10,11,12,..
I suppose it is like this: 1,2,3,4,5,6,...12,..
can anyone help on this pls?
thanks in advance.
Regards,
Show Column In Listview
I sort a column in a listview, say column 10, by date. the only way I could do this was to reload the listview from a recordset.
I then want to have this column showing, but without reordering the columns.
I have another thread going, here but it seems from the help I have gratefully been given there, that I would need to use Common Controls Version 5, not 6 to do this. Version 6 has a lot more to it, and things that I don't want to give up.
Does anybody know if this is possible to do with version 6?
Show Images In A Listview
I have a list of filenames (image files) in a listbox. The user can add or remove filenames in it. I have to show the thumbnails of the files in a listview control. How can i do that? I tried it but got some errors. can anybody give me the code to do it?
Show Files In Listview
Hi,
This is simple Question. I've done it b4 but have 4go10 how to do it. Basically I want to populate a LISTVIEW control with the "filename","filetype and "filesize" of all the files in the path of my DIRLIST control. Meaning, everytime the path changes in the DIRLIST control the the above info should be populated in this LISTVIEW. I need the urgently.
I also need a TREEVIEW control which is populated with the entire directory structure of all drives.
Show Different Text From ListView
With ListView 6.0 in VB6:
When a ListView is displayed, I want to have some of the
subitems text displayed differently (without modifing the subitem's value). i.e. show subitem(1)values +1
Im sure I have seen this done...
Listview Does Not Show Records
I have a listview control on my form, and when I step throught he code I can see the items being added, but they do not display. I copied the code exactly from one that works but can't figure out why mine wont work.
CODEFor Each oCustomer In mCustomers
Dim objListItem As ListItem
Dim objListSubItem As ListSubItem
With oCustomer
Set objListItem = lvwCustomers.ListItems.Add
objListItem.Key = "S" & Str(.OID)
objListItem.Text = .CustomerNumber
Set objListSubItem = objListItem.ListSubItems.Add(, , .CustomerName)
End With
Next
Search And Show Listview
Hi Everyone,
I'm new to VB6 so please bare with me. I wrote a small program to keep users info in Access database using DAO. Now, I need to retrieved the information and show it up in listview(lvwreport). Can anyone show me how to do a search for lastname or firstname and show all records that matches the search to listview(lvwreport)?
Thank you
ListView Blues. Please Show Me How To ...
I'm beginning to hate the listview! I have a textbox (only 1) that is saved to a file. Whenever an item in LV is selected, the user can open the textbox and type something ... Like "Charity" or "Donation."
I don't want the values from the listview. I want whatever goes in the textbox to relate to only the item that was selected so when it's reopened, it will display what was entered for that particular item. I'm using VB5 and no database. The listview has 62 items. Please don't tell me I have to create 62 text files!
The following code saves and loads the textbox but it's not specific to the item that was selected. Say if "Donation"
was entered, it shows "Donation" for every item in LV and that's not the way it's suppose to be! If you can, please help.
Code:Open "d:Test2.txt" For Input As #FF
Do While Not EOF(FF)
Line Input #FF, Me.txt1
'Me.txt1 = Me.txt1 & sLine 'Was multiline
Loop
Close #FF
Code:Open "d:Test2.txt" For Output As #FF
Print #FF, Me.txt1.Text
Close #FF
Edited by - PrissysHonor on 3/13/2006 12:25:26 PM
How To Show The Selected Item In A Listview?
I want to be able to show the selected item in a listview. I'll try to explain by an example.
Visible items:
Item 1
Item 2
Item 3
Item 4
Invisible items:
Item 5
Item 6
Item 7
Item 8
Now when I select Item 8 by the use of source code like this:
listview.listitems(8).selected = true
I want to scroll the listview so that the item becomes visible. So how do I scroll the listview to the selecteditem with source?
Show Last Item Added In Listview.
Hello there! I just wanted to ask if there's any way to display or go to the last item added in a listview. I have this attendance system and it's working out fine. But they want to see that during scanning, their name should be displayed as it's added to the listview. There will be no user intervention by the way as the computer is inside a cabinet with just the barcode scanner the interact with.
Show Individual Item In Listview
I have a problem seen the firs column in a listview
If i put
ListView1.ListItems(i).ListSubItems(0)
it gives an error index out of range.
If i put ListView1.ListItems(i).ListSubItems(1) it shows me the item in the second column. how do I see the info in the first one?
Show Its Productid Starting From... Listview
My listview is working fine, now how do I show its productid column starting from the record that equal to the txtcode.text and above.
Code:
Private Sub SearchId_Click()
'set everything up
Dim strSQL As String
If txtkode.Text <> "" Then
con_Data.BeginTrans
'On Error Resume Next
'find Productid from tabel
'msql = "select * from product " & _
" where productid='" & txtkode.Text & "'"
'connect to the database
' Set objCn = New ADODB.Connection
' objCn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "
ecordsetpaging.mdb;" & _
"Persist Security Info=False"
' objCn.Open
'set up the recordset (but we dont fill it until after setting paging info)
' Set objRs = New ADODB.Recordset
strSQL = "SELECT productid, productname, unit, partnumber, brand " _
& "FROM product " _
& "ORDER BY productid " '& "where productid = '" & txtkode.Text & "'" _
' strSQL = "SELECT FName, LName, DOB, EmpNumb, DOH " _
& "FROM tblemployeeinfo " _
& "ORDER BY LName "
'to ensure we get a RecordCount for our label, set the cursor location to Client
Rs.CursorLocation = adUseClient
'set up the paging.
'the page size specifies how many records are on each page
Rs.PageSize = intRecordsPerPage
'the cache size specifies how many records should be stored in memory
'If Cachesize and PageSize are equal (as they are here) then only
'the records to be displayed will be cached in the recordset
Rs.CacheSize = intRecordsPerPage
'open the recordset - as there is no WHERE clause on the query, all 31 records
'in the included example db table will be captured in the recordset.
Rs.Open strSQL, con_Data, adOpenStatic, adLockReadOnly
lblRecordCount.Caption = Rs.RecordCount & " records are contained in the recordset."
'PageCount simply tells us how many pages there are in our recordset object
intPageCount = Rs.PageCount
'show the data
intPage = 1
'Call HflexGrid
'MSHFlexGrid1.Visible = True
Call ShowPage
con_Data.CommitTrans
SearchId.Enabled = False
Else
MsgBox "Pls fill-in id"
End If
End Sub
Code:
Private Sub ShowPage()
'shows a "page" of records
Dim intRecord As Integer
Dim lvwItem As ListItem
'move to the appropriate page of the recordset
Rs.AbsolutePage = intPage
'clear the control
lvw.ListItems.Clear
'The For loop will display just the number of records we specified
For intRecord = 1 To Rs.PageSize
'add the data to the control
'(change these lines to suit your fields, and the control you are using)
Set lvwItem = lvw.ListItems.Add(, , Rs.Fields.Item("productid").Value)
lvwItem.SubItems(1) = Rs.Fields.Item("productname").Value
lvwItem.SubItems(2) = Rs.Fields.Item("unit").Value
lvwItem.SubItems(3) = Rs.Fields.Item("partnumber").Value & vbNullString
lvwItem.SubItems(4) = Rs.Fields.Item("brand").Value & vbNullString
'move to the next record within this page
Rs.MoveNext
'if we have run out of records (which we may on the last page) exit the loop
If Rs.EOF Then Exit For
Next intRecord
'show the page number
lblPageInfo.Caption = "Page " & intPage & " of " & intPageCount
'enable/disable buttons as apt
cmdPrev.Enabled = (intPage > 1)
cmdFirst.Enabled = (intPage > 1)
cmdNext.Enabled = (intPage < intPageCount)
cmdLast.Enabled = (intPage < intPageCount)
End Sub
any help are welcome.
thanks in advance.
Regards,
Show Selected Column (Listview)
I have a listview with approx 20 columns, 4 of which are dates.
When I scroll along to one of these dates columns, and click on the columnheader to sort that column, I clear the listbox and reload in the sort order by recalling the data from the database via a recordset.
The problem is, although the data is sorted as I want, the column that has the sort on it is now not showing. I have to scroll back along to show it.
How can I set it so that the column that has the sort on it is visible?
I looked for an 'EnsureVisible' property, but either I have missed it somehow, or that isn't the way to go.
Fail Show Dbf Record In Listview
Hi, expert,
I have a problem to read the dbf file and show the record in listview.I gather all dbf file in 'data' folder.So I try to access the dbf file in 'data' folder.So the path of dbf file,is located in this location in C:ProjectData. In 'data' folder,it have 3 directory, data1 (soil.sbf), data2(Parcel.dbf), data3(address.dbf).. So how I can access the file for 3 dbf file in the directory by using parent folder?Does I need to do like this?Parent data is ' data folder' the chile is 'data1' , data2, data3.
C:ProjectDatadata1
C:ProjectDatadata2
C:ProjectDatadata3
or like this C:ProjectData so that it can access the dbf data in parent location only.
Dim cnn As New ADODB.Connection
Dim pCommand As New ADODB.Command ' baru tambah
Dim dbf_name As String
Dim dbf_path As String
Dim rs As New ADODB.Recordset
Dim fld As ADODB.Field
Dim colHeader As ColumnHeader
Dim itemX As ListItem
Dim layerIndex As Integer
dbf_path = "C:ProjectData"
dbf_name = "blockc.dbf" ' I don't know how to code this line
Dim conStr As String
conStr = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" & dbf_path & ";Exclusive=No;"
cnn.Open conStr
rs.Open dbf_name, cnn, adOpenStatic, adLockReadOnly, adCmdTable
ListView2.ListItems.Clear ' clear list view untuk list rekod baru
ListView2.ColumnHeaders.Clear ' clear field coloum list field baru
ListView2.View = lvwReport
Using A ListView To Show Contents Of A Folder
How do I use a ListView control to show the contents of a folder? I am currently using a FileList which is updated depending on the selections made in DriveList and DirList controls. Also, would I be able to use it to filter out hidden/system files and certain file extensions?
Cheers in advance!
Show Icons Against ListView Items
Hi
Can I show items in a ListView with icons becide each item. I would like that icon to describe the item. Do I have to use a different control ?
Thanks
Robert
Take Values From Registry And Show In Listview!
How can I read all the values names and their values from a given registry folder and show them in a listview? I have declared the variables needed to read the registry as follows:
Quote:
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Const REG_SZ = 1
Private Const LOCALMACHINE = &H80000002 ' This is really HKEY_LOCAL_MACHINE
I know to read a value from a registry, the following command is used (It will take the value of item "Username" from the registry folder "HKEY_LOCAL_MACHINESOFTWAREMy ApplicationLogin" and show it in Text1.Text ):
Quote:
Dim nBufferKey As Long, nBufferSubKey As Long
Dim nBufferData As String
nBufferData = Space(256)
RegOpenKey LOCALMACHINE, "SOFTWAREMy Application", nBufferKey
RegOpenKey nBufferKey, "Login", nBufferSubKey
'======== TAKE FROM REGISTRY ===========
RegQueryValueEx nBufferSubKey, "Username", 0, REG_SZ, nBufferData, Len(nBufferData)
Text1.Text = nBufferData
What I want to do is to read all the values in a given registry folder and show all these in a listview. There may be many many values in this folder. When the form loads, I want to list all these value names alongwith their values shown in a listview in two columns. Thanx in advance !!!
Listview Wont Show The + Symbol ?
Have any of you had this problem ?
I'm adding items to a listview, and for some reason it just wont show a + item indicating that a listitem has subitems.
I've messed with the settings etc.
Here's the snippet of code doing the adding.
Basically its reading report files from a directory, and then adding the name of the computer to the listview, 'ordered' or listed under the domain name of the computer.
They're just simple string values.
Uhn this is a pain.
The subitems are being added, but there's no +.
So if you doubleclick on an item, it does show stuff below it, but thats is
VB Code:
Do While myName <> "" DoEvents If myName <> "." And myName <> ".." Then If Len(myName) >= 4 Then If Right(myName, 4) = ".dat" Then Open myPath & myName For Binary As #1 Get #1, 1, systemReportInformation(i) systemReportInformation(i).aReportOnComputer = systemReportInformation(i).aReportOnComputer & " " & Format(i, "000") systemReportInformation(i).hNetworkingInformation.domain = "domain " & domain(i Mod 5) found = False For n = 0 To UBound(domainsDone) If domainsDone(n).name = systemReportInformation(i).hNetworkingInformation.domain Then TreeView1.Nodes.Add domainsDone(n).nodX, tvwChild, , systemReportInformation(i).aReportOnComputer found = True Exit For End If Next If Not found Then ReDim Preserve domainsDone(UBound(domainsDone) + 1) domainsDone(UBound(domainsDone)).name = systemReportInformation(i).hNetworkingInformation.domain Set domainsDone(UBound(domainsDone)).nodX = TreeView1.Nodes.Add(, , domainsDone(UBound(domainsDone)).name, domainsDone(UBound(domainsDone)).name) TreeView1.Nodes.Add domainsDone(UBound(domainsDone)).nodX, tvwChild, , systemReportInformation(i).aReportOnComputer End If i = i + 1: If i = 20 Then Exit Do ReDim Preserve systemReportInformation(i) Close #1 End If End If End If myName = Dir Loop
Show Icon Of Exe File In Listview
Hi
I read one tip in vb-world about extract icon from exe or dll file. I did it successfully. The problem is, I try to put that Picture object in ImageList for use with ListView but it give me an error "Out of Memory"!!!!!
Anyone know how to get to icon from exe file an put it in listview, Please help.
Thanks in advance
Show Multiple Items In Listview Taken From Database
How would I show multiple items from an Access database in a listview?
Example: Let's say my database looks like this:
Sender Subject Date
me@isp.com Some Subject 1-13-00 7:59AM
you@otherisp.com Some other subject 7-30-01 8:00AM
I want to load both items into a listview. My current procedure only loads one item at a time. Here is the procedure:
Code:
Dim Recordset As ADODB.Recordset
Select Case Node.Text
Case "Trash"
If Recordset.EOF = True Then Exit Sub
lvwMail.ListItems.Clear
With lvwMail.ListItems.Add(, , Recordset!Sender)
.SubItems(1) = Recordset!Subject
.SubItems(2) = Recordset!Date
End With
End Select
Dont Show Scroll Bars In Listview
How do I stop the scroll bars (vert and horz) from appearing
in the ListView control. (report mode)
my information will be bigger than the window, but will be scrolled by the program only.
Show Icon In ReportView Of A ListView Control
I'd like to be able to show an icon in one column of the listview control when it's .View property is set to lvwReport i.e Report View.
If this is possible and anyone knows how to do it, i'd like to know thw solution.
Thanks
How Can I Show Data From Access DB Into Listview As Report?
Hello All!
Because in the last few weeks I got a lot of new clients to fix their pc's & laptops I decided to make my self a program wrotten on VB to have all my clients information & detailes about what I did to their pc's & laptops....
So I opened my VB program & started to develop something, though I got stucked!!
My DB table culmns looks like: First name, Last name, phones, IM, Address, price, detailes
I got succefully conectted to the DB, & succefully I've got the .string I was searching ex. ( Select * From Table1 by order First name )
Though, i don't need to see it as a 1 string, i need to get it like in a report, I set my listView1 to have sub items.. & I want that every culmn will be in the specific culmn ( sub item ) inside the Listview, How can I do that?
Thanks in advance, yous, Yoni D.
Right Click On Listview - Show Menu (like In Windows)
Hi. I was wondering if you can do the following in vb: click on a row in a listview (or on an object) and be able to display a short menu (where you clicked) with options available on that object (row in listview). Thanks
T M
Show ListItem (ListView MultiLine Data) Ideas
Hi to all, I need some ideas, I have one but I'm looking for the best an faster idea.
that I'm trying to do is this: My program have the Search Section, and sends all results into a ListView, but some data is a MultiLine data, currently is showed in a sinlge line, my current idea is to show a ToolTipo box when the user selects one listitem, show the data contained in that field (MultiLine text), also someone tells me to use a Form designed as ToolTip box, then I need more ideas about how show this data.
Thanks
Select Treeview Node - Find In Db - Show In Listview
i use VB6, SQL SERVER 2k
i have a treeview with is populated from 3 tables using the code below
when i select a node i would like to feed a listbox with the appropriate data.
how can i find the correct record in the correct table in the db
when the node is selected.
all i can think of is by using the node.key but through my code i dont think this would be pretty much helpful.
is there a better way to populate my treeview, or a way to find the proper record in the proper table in the db?
Code:
' Add Node objects.
Dim nodX As Node ' Declare Node variable.
'root node
Set nodX = TreeView1.Nodes.Add(, , "root", "App.ProductName")
'tree structure
Set nodX = TreeView1.Nodes.Add("root", tvwChild, "child1", "Types")
Set rs2 = New ADODB.Recordset
rs2.Open "SELECT * FROM DevType", cn, adOpenKeyset, adLockOptimistic, adCmdText
'if types exist add them to structure
If rs2.RecordCount > 0 Then
Dim i
i = 1
rs2.MoveFirst
Do Until rs2.EOF
Set nodX = TreeView1.Nodes.Add("child1", tvwChild, "child1-" & i, rs2!Name)
Set rs3 = New ADODB.Recordset
rs3.Open "SELECT AppName,ApplicationID FROM DevApplication WHERE ApplicationID = (SELECT DISTINCT ApplicationID FROM DevVersions WHERE TypeID = " & rs2!TypeID & ")", cn, adOpenKeyset, adLockOptimistic, adCmdText
'if applications exist add them
If rs3.RecordCount > 0 Then
Dim k
k = 1
rs3.MoveFirst
Do Until rs3.EOF
Set nodX = TreeView1.Nodes.Add("child1-" & i, tvwChild, "child1-" & i & "-" & k, rs3!AppName)
Set rs4 = New ADODB.Recordset
rs4.Open "SELECT Name FROM DevVersions WHERE ApplicationID =" & rs3!ApplicationID, cn, adOpenKeyset, adLockOptimistic, adCmdText
'if application has versions add them
If rs4.RecordCount > 0 Then
Dim e
e = 1
rs4.MoveFirst
Do Until rs4.EOF
Set nodX = TreeView1.Nodes.Add("child1-" & i & "-" & k, tvwChild, "child1-" & i & "-" & k & "-" & e, rs4!Name)
e = e + 1
rs4.MoveNext
Loop
End If
rs4.Close
Set rs4 = Nothing
k = k + 1
rs3.MoveNext
Loop
End If
rs3.Close
Set rs3 = Nothing
i = i + 1
rs2.MoveNext
Loop
End If
rs2.Close
Set rs2 = Nothing
the tables structures in short, are
1. applications (name,idz,etc)
2. Types (aka. application types)
3. Versions (which relates the above two.)
thanxs in advance
|