| | |
problem in making listview
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
hello, by the way im using datagrid in showing all the data in my database...
here my codes...
'''''''''''''''''''''''''''
form_load
set rs = orecs ("select * from employee")
set datagrid = rs
'''''''''''''''''''''''''''
how can i convert it in list view to view all the data in my database.........
plssssssss kindly help me.........
jaasaria
here my codes...
'''''''''''''''''''''''''''
form_load
set rs = orecs ("select * from employee")
set datagrid = rs
'''''''''''''''''''''''''''
how can i convert it in list view to view all the data in my database.........
plssssssss kindly help me.........
jaasaria
Try use this sample code
vb Syntax (Toggle Plain Text)
Private Sub tv1_NodeClick(ByVal Node As MSComctlLib.Node) LV1.ListItems.Clear rs.Open "select * from EMP", con, adOpenDynamic, adLockOptimistic Dim li1 As ListItem Set li1 = LV1.ListItems.Add() If Not rs.EOF Then If IsNull(rs(0)) Then li1.Text = "" Else li1.Text = rs(0) End If If IsNull(rs(1)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(1) End If If IsNull(rs(2)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(2) End If If IsNull(rs(3)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(3) End If If IsNull(rs(4)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(4) End If If IsNull(rs(5)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(5) End If If IsNull(rs(6)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(6) End If If IsNull(rs(7)) Then LV1.ListItems(1).ListSubItems.Add , , "" Else LV1.ListItems(1).ListSubItems.Add , , rs(7) End If End If rs.Close End Sub
Share your Knowledge.
check out this sample, try it and give your feedback.
regards
Shouvik
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim str As String Dim rs As New ADODB.Recordset Dim li As ListItem str = "select * from org_master order by org_id" rs.open str, ADODB.adOpenDynamic, ADODB.adUseClient, ADODB.adLockOptimistic lvoffice.ListItems.Clear If rs.RecordCount > 0 Then rs.MoveFirst While Not rs.EOF() With lvoffice Set li = .ListItems.Add(, , (rs!org_id)) li.SubItems(1) = Replace(rs!org_name, Chr(5), ", ") li.SubItems(2) = IIf(IsNull(rs!Description), "", Replace(rs!Description, Chr(5), ", ")) End With rs.MoveNext Wend End If If rs.state = adStateOpen Then rs.Close Set rs = Nothing
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
elow ..choudhuryshouvi..
the code that you given was an error to my system...(invalid property value)
i dont know wat the problem but i dont know the purpose of chr(5)..
can you make another to right for me..
elow..debasisdas...
by the way the code that you given it not working....
their no error but only listview without any data...
my datagrid contain some..but my listview dont have any one...
plzzzzzzzzzz help me guyzzzzzzzzzzzz...
thx for the post
the code that you given was an error to my system...(invalid property value)
i dont know wat the problem but i dont know the purpose of chr(5)..
can you make another to right for me..
elow..debasisdas...
by the way the code that you given it not working....
their no error but only listview without any data...
my datagrid contain some..but my listview dont have any one...
plzzzzzzzzzz help me guyzzzzzzzzzzzz...
thx for the post
there is no relation of chr(5) with the error "invalid property value".
this "chr(5)"was used by me in one of my application to retrieve value from one of the tables after just replacing the ascii code of vbnewline to ",".you can skip this character. there is no need of it in your code.
do you know what is the meaning of this error msg?
if don't then listen,
vb6 compiler returns this error if any column to which you are adding data doesn't exist in the listview at all.
you must have similar number of columns in the listview the no. of times you fire this li.subitems statement before adding data.
in this command li.subitems(1), the numeral within the paranthesis refers to the column to which you are adding data. you can consider it like an array. but in this case the lbound starts from 1. if the compiler doesn't find the column at the specified index position in the listview it fetches you "invalid property value" error.
to add data into the first col of the lv you use
set li=.listitems.add(,,(<your data to be added>))
then from second to n-th no. of columns you use li.subitems(<col. index no.>)=<your data to be added>
so as much as i told u the error was in your target lv not in the code and it would never be because it was used in several forms of my application and tested many times.
so before run this code make sure you have sufficient no. of columns in your listview control.
e.g., in the sample code that i gave you, the listview should contain atleast 3 columns to successfully complete execution of the code.
i hope this lecture will help you to solve your problem.
ok.....
don't forget to tell me what hv u got
regards
Shouvik
this "chr(5)"was used by me in one of my application to retrieve value from one of the tables after just replacing the ascii code of vbnewline to ",".you can skip this character. there is no need of it in your code.
do you know what is the meaning of this error msg?
if don't then listen,
vb6 compiler returns this error if any column to which you are adding data doesn't exist in the listview at all.
you must have similar number of columns in the listview the no. of times you fire this li.subitems statement before adding data.
in this command li.subitems(1), the numeral within the paranthesis refers to the column to which you are adding data. you can consider it like an array. but in this case the lbound starts from 1. if the compiler doesn't find the column at the specified index position in the listview it fetches you "invalid property value" error.
to add data into the first col of the lv you use
set li=.listitems.add(,,(<your data to be added>))
then from second to n-th no. of columns you use li.subitems(<col. index no.>)=<your data to be added>
so as much as i told u the error was in your target lv not in the code and it would never be because it was used in several forms of my application and tested many times.
so before run this code make sure you have sufficient no. of columns in your listview control.
e.g., in the sample code that i gave you, the listview should contain atleast 3 columns to successfully complete execution of the code.
i hope this lecture will help you to solve your problem.
ok.....
don't forget to tell me what hv u got
regards
Shouvik
Last edited by choudhuryshouvi; Mar 1st, 2008 at 3:58 am.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
ok i took the customer table and this is the code for it.
focus on the bolded part.
also see the snapshot.
regards
Shouvik
focus on the bolded part.
Dim db As Database
Dim rs As Recordset
Dim li As ListItem
Set db = OpenDatabase(App.Path & "\asa.mdb")
Set rs = db.OpenRecordset("customer", dbOpenTable)
If rs.RecordCount > 0 Then
rs.MoveFirst
While Not rs.EOF()
With lvcustomers
Set li = .ListItems.Add(, , (rs!cus_num))
li.SubItems(1) = IIf(IsNull(rs!cus_name), "", rs!cus_name)
li.SubItems(2) = IIf(IsNull(rs!cus_tel), "", rs!cus_tel)
li.SubItems(3) = IIf(IsNull(rs!cus_add), "", rs!cus_add)
End With
rs.MoveNext
Wend
End Ifalso see the snapshot.
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
•
•
•
•
elow..debasisdas...
by the way the code that you given it not working....
their no error but only listview without any data...
my datagrid contain some..but my listview dont have any one...
Try to run the code in debug mode and check .
Actually that code was to populate the list view from a tree view selection.
Try using on button click event
Last edited by debasisdas; Mar 3rd, 2008 at 6:02 am.
Share your Knowledge.
hi,
i have found this post somewhat close to solving my problem, but there seem to be a problem. Kindly help me with the code....i am posting the code
But nothing gets displayed on the Listview..... actually i am searching a particular book name
i will be grateful for anykind of help..
thanks.
i have found this post somewhat close to solving my problem, but there seem to be a problem. Kindly help me with the code....i am posting the code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Set db = OpenDatabase(App.Path & "\libraryic.mdb") Set rs = db.OpenRecordset("Book_Details", dbOpenTable) ''Do While Not Form1.Data1.Recordset.EOF ''Data1.Recordset.MoveNext ''While Not Data1.Recordset.EOF If rs.RecordCount > 0 Then rs.MoveFirst While Not rs.EOF() With BooK_Details li = .ListItems.Add(, , (rs!Acc_No)) li.SubItems(1) = IIf(IsNull(rs!Book_Name), "", rs!Book_Name) li.SubItems(2) = IIf(IsNull(rs!Author), "", rs!Author) li.SubItems(3) = IIf(IsNull(rs!Publisher), "", rs!Publisher) li.SubItems(4) = IIf(IsNull(rs!Stock), "", rs!Stock) End With rs.MoveNext Wend
But nothing gets displayed on the Listview..... actually i am searching a particular book name
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Form7.Data1.RecordSource = "select * from Book_Details where Book_Name like '" & SearchStr$ & "%'" ' or Book_Name like '" & SearchStr$ & "'" Form7.Data1.Refresh
i will be grateful for anykind of help..
thanks.
You cant get to where you are going unless you know where you have been.
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB Image resources and using them
- Next Thread: plss give me some codes using palindrome in visual basic 6.0
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column 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 retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






