|
-
October 24th, 2002, 02:31 AM
#1
listview
if im going to use listview, how can a put the record on it? i want to get the records from a recordset.
Is it possible tu put textbox and checkbox on the listview at the same time?
Pls help thanks!!!
Last edited by kristine2002; October 24th, 2002 at 03:31 AM.
Thanks!!!
Kristine
-
October 24th, 2002, 08:09 AM
#2
An Example
Here is an example I use Hope this will help You
Sub Load Tests()
ListView2.ListItems.Clear
ListView2.ColumnHeaders.Clear
ListView2.ColumnHeaders. _
Add , , "Tests", 2030, lvwColumnLeft
ListView2.ColumnHeaders. _
Add , , "Rate", 1000, _
lvwColumnRight
' Set View property to Report.
ListView2.View = lvwReport
SString = "specimen = '" & ComboSpc & "'"
Rs.Open "select Testname, rate FROM testTable Where (" & SString & " and Testname is Not Null) Order by Testname", CN, adOpenDynamic, adLockOptimistic
Dim itmX As ListItem
While Not Rs.EOF
Set itmX = ListView2.ListItems. _
Add(, , UCase(Rs!testname)) ' testname
itmX.SubItems(1) = Format((Rs!Rate), "0.00")
Rs.MoveNext ' Move to next record.
Wend
Rs.Close
End Sub
VbBaby
-
October 24th, 2002, 09:30 AM
#3
listview (another question)
Hi! Thanks for the help. But i still have two more problems. How can i put textbox and checkbox on a listview control. I know that you can set the checkbox property to true to display a checkbox on the listview, but how about textbox? Is it possible?
Is there a way to know what column was click on a listview if it has several columns in it? Because i want to use listview the same way as datagrid.
I'll really appreciate your help. Thanks in advance
Last edited by kristine2002; October 24th, 2002 at 09:33 AM.
Thanks!!!
Kristine
-
October 24th, 2002, 09:55 AM
#4
Hello
I am not sure why you want to put a text box on a ListView Control. And What is the problen to Put one on the list view control. Why not just draw text box on Listview?
In listview control the colum is determined by the proppeety
ListView1.SeletedItem. Subitem(Index)
Will You Please explain what is your Idea Behind putting a text box on it??
VbBaby
-
October 24th, 2002, 10:28 AM
#5
-
October 24th, 2002, 02:41 PM
#6
You can set the listview property LabelEdit to automatic. That allows the user to edit each field.
Here is a piece of code that I made for any recordset size or whatnot. However I use MSFlexGrid instead of a Listview. I am sure you can figure out how to use it in Listview. It does crash if there are too many records but I added more code to handle it which I didn't post here but again it can be coded.
Dim i As Integer
Dim j As Integer
Dim intCount As Double
Set mRS = RecSet
With mRS
'change the number of columns in grid
msgGrid.Cols = .Fields.Count
.MoveLast
'change the number of rows in grid
If .RecordCount > 5000 Then
msgGrid.Rows = 5001
mlngStartRecord = 1
mlngLastRecord = 5000
mblnMultiple = True
Else
msgGrid.Rows = .RecordCount + 1 'add one more for header row
mlngStartRecord = 1
mlngLastRecord = .RecordCount
mblnMultiple = False
End If
.MoveFirst
' Create a header row using the field names and column widths
For i = 0 To .Fields.Count - 1
msgGrid.Row = 0
msgGrid.Col = i
'write the name to the grid cell
msgGrid.Text = .Fields(i).Name & ""
'set the header column width.
msgGrid.ColWidth(i) = CLng(Len(.Fields(i).Name)) * 104
intCount = intCount + msgGrid.ColWidth(i)
Next i
'change the width of the from to match with the width of the grid
'unless the grid is wider than the screen itself then set to screen width
If (intCount + 400) < Screen.Width Then
Me.Width = intCount + 400
Else
Me.Width = Screen.Width
Me.Left = 0
End If
'Now fill the grid with all the values in recordset
'start with 1 since 0 is header row
For i = mlngStartRecord To mlngLastRecord
'set the row current
msgGrid.Row = i
'populate each column with field value
For j = 0 To .Fields.Count - 1
'set the column
msgGrid.Col = j
'write the value to the grid cell
msgGrid.Text = .Fields(j).Value & ""
Next j
'move to the next record
.MoveNext
Next i
End With
-
October 24th, 2002, 05:35 PM
#7
I've posted the code we use for filling, editing, deleting etc from a listview (with Icons) here in a zipfile. To use it properly, the "edit" form needs to have the properties used by the 'viewstaticdata' form declared.
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
|