|
-
Dec 21st, 2005, 05:15 AM
#1
Thread Starter
Fanatic Member
Re: List View Control
 Originally Posted by yesfriends
try this..
This is also not working. But there is no error also. Simply the listview is empty.
-
Dec 21st, 2005, 05:22 AM
#2
Junior Member
Re: List View Control
hi create one command button name cmdLoadListView...at onclick event of this command button write below code..
VB Code:
Dim sSQL As String
Dim lvwItem As ListItem
Set rs = New ADODB.Recordset
sSQL = "SELECT [NAME] FROM TBL1 "
rs.Open sSQL, db
Do Until rs.EOF
Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
-
Dec 21st, 2005, 05:50 AM
#3
Thread Starter
Fanatic Member
Re: List View Control
 Originally Posted by yesfriends
hi create one command button name cmdLoadListView...at onclick event of this command button write below code..
VB Code:
Dim sSQL As String
Dim lvwItem As ListItem
Set rs = New ADODB.Recordset
sSQL = "SELECT [NAME] FROM TBL1 "
rs.Open sSQL, db
Do Until rs.EOF
Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Yeah, it is working fine. But please let me know why can't we view the contents without using the commond button (like datagrid)?
How can I view it in a lvwReport view. I have modified LISTVIEW property to 3 lvwReoprt. But now I can not view any data?
Please help.
-
Dec 21st, 2005, 05:54 AM
#4
Re: List View Control
Fine remove the command button but it should still work. What i wrote means that it will load the listview no matter what and it will also do it if you press the button, but you can remove the button and it should work
Last edited by Andrew G; Dec 21st, 2005 at 06:31 AM.
-
Dec 21st, 2005, 06:05 AM
#5
Thread Starter
Fanatic Member
Re: List View Control
[/QUOTE]
then it runs when you open the form and when you click on the command button[/QUOTE]
I dont want to use commond button to view the listview. When I open the project it should show automatically all the data in a ListView (lvwReport view). Is it possible?
-
Dec 21st, 2005, 06:10 AM
#6
Junior Member
Re: List View Control
u write this code with form onload event....and when ur form will load then it automatically populate ur list view..
VB Code:
Dim sSQL As String
Dim lvwItem As ListItem
Set rs = New ADODB.Recordset
sSQL = "SELECT [NAME] FROM TBL1 "
rs.Open sSQL, db
Do Until rs.EOF
Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
-
Dec 21st, 2005, 06:20 AM
#7
Thread Starter
Fanatic Member
Re: List View Control
When I add the code to Form Load, It shows nothing. The following is the code:
Private Sub Form_Load()
Call data_connect
rs.Open "Select * from TBL1", db
Set DataGrid1.DataSource = rs
show_rec
Dim sSQL As String
Dim lvwItem As ListItem
Set rs = New ADODB.Recordset
sSQL = "SELECT [NAME] FROM TBL1 "
rs.Open sSQL, db
Do Until rs.EOF
Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|