| | |
Help with Search & ListView codes.
![]() |
Hi, hope everyone here is dong fine.
Can anyone please help me with my coding.
This is the code to fetch the book name from INPUT box and display it in a TextBox(which is limited). But I want the records to be displayed on a ListView with several others having similar(closest to) name. But I am struggling with the code on how to show the records in ListView.
I tried to create the columns using this codes:
Which is not working!!
And how do i add the records from the database??
Basically I am struggling with the code to display the records on ListView from the Database. Can anyone please give me some hints.
Thanks a lot.
Can anyone please help me with my coding.
This is the code to fetch the book name from INPUT box and display it in a TextBox(which is limited). But I want the records to be displayed on a ListView with several others having similar(closest to) name. But I am struggling with the code on how to show the records in ListView.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
prompt$ = "Please enter the book name" SearchStr$ = InputBox(prompt$, "book title search") Data1.Recordset.MoveFirst Data1.Recordset.FindFirst "Book_Name='" & SearchStr$ & "'" If Data1.Recordset.NoMatch Then MsgBox "No match found", vbInformation, "" Else Form7.Show Form7.Data1.RecordSource = "select * from Books where Book_Name = '" & SearchStr$ & "'" ‘hope I can use LIKE with % to display more similar names Form7.Data1.Refresh Form7.Text1.Text = Form7.Data1.Recordset.Fields(0) Form7.Text2.Text = Form7.Data1.Recordset.Fields(1) Form7.Text3.Text = Form7.Data1.Recordset.Fields(2) End If
I tried to create the columns using this codes:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
ListView1.Columns.Add("Title", 10, HorizontalAlignment.Left)
And how do i add the records from the database??
Basically I am struggling with the code to display the records on ListView from the Database. Can anyone please give me some hints.
Thanks a lot.
You cant get to where you are going unless you know where you have been.
•
•
•
•
Basically I am struggling with the code to display the records on ListView from the Database. Can anyone please give me some hints.
Listview.listItems.Add Index, Key, Text, Icon, SmallIcon as ListItem If you're using a database recordset, you might try using a loop with the EOF property.
With MyDatabase
.MoveFirst
while Not .EOF
ListView1.ListItems.Add , , .Fields("MyFoundField")
.MoveNext
Wend
End withI don't use these listviews much; but I think that the Columns property is intended to design the listview on the fiy. If you want to add items, I would say to use the ListItems Method.
Last edited by hkdani; Nov 24th, 2008 at 5:05 pm.
Thanks hkdani for the help. I have tried it in the application and its working(partly). I can display the data’s in ListView. But it just displays the data’s in a random manner and also without column names. (no rows or columns….just one line or in multiple lines)
I first query for a name in my Find/Search text box like,
I hope this is a standard code… and then result of this query is to be displayed in a ListView1. So I used your code..
Now this code displays the data’s but without the column names and that too in a random manner. Can anyone please suggest how to correct this.
Thanks again.
I first query for a name in my Find/Search text box like,
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
select * from Book_Details where Book_Name = '" & SearchStr$ & "' or Book_Name like '%SearchStr%'"
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With Data1.Recordset .MoveNext While Not .EOF Form11.ListView1.ListItems.Add , , .Fields("Book_Name") Form11.ListView1.ListItems.Add , , .Fields("Author") ………………. ……………. .MoveNext Wend End With
Thanks again.
You cant get to where you are going unless you know where you have been.
http://msdn.microsoft.com/en-us/libr...52(VS.60).aspx
The above was just my meager attempt to get you started. You need to use the report format. The MSDN link above should give you the information you need to accomplish your task.
Hank
The above was just my meager attempt to get you started. You need to use the report format. The MSDN link above should give you the information you need to accomplish your task.
Hank
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: change column width in MSFlexgrid
- Next Thread: Multilingual VB6 application sample
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





