|
-
May 8th, 2006, 06:07 PM
#1
Thread Starter
Fanatic Member
Listview Error
Hi
I see example below:
Code:
Dim itmX As ListItem ' Create a variable to add ListItem objects.
Dim clmX As ColumnHeader ' Create an object variable for the ColumnHeader object.
' Add ColumnHeaders.
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 1", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 2", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 3", ListView1.Width / 3)
ListView1.BorderStyle = ccFixedSingle ' Set BorderStyle property.
ListView1.View = lvwReport ' Set View property to Report.
' Add a main item
Set itmX = ListView1.ListItems.Add(, , "First value")
' Add two subitems for that item
itmX.SubItems(1) = "First value subitem 1"
itmX.SubItems(2) = "First value subitem 2"
But when I put in my code
Code:
Set itmX = lvw_profissional.ListItems.Add(, , Ret_Sql.Fields("TB02_PK"))
itmX.SubItems(0) = "xxxx"
It return me error Invalid property value
-
May 8th, 2006, 06:18 PM
#2
Re: Listview Error
SubItems are 1 based collection:
change itmX.SubItems(0) to itmX.SubItems(1)
-
May 8th, 2006, 06:19 PM
#3
Re: Listview Error
shouldn't it be:
VB Code:
itmX.SubItems(1) = "xxxx"
Edit: Dang! too slow.
-
May 8th, 2006, 06:25 PM
#4
Thread Starter
Fanatic Member
Re: Listview Error
I tried , but do not work
Code:
Set itmX = lvw_profissional.ListItems.Add(, , Ret_Sql.Fields("TB02_PK"))
itmX.SubItems(1) = Trim(Ret_Sql("TB02_NOME").Value)
Invalid property value
-
May 8th, 2006, 06:31 PM
#5
-
May 8th, 2006, 06:41 PM
#6
Thread Starter
Fanatic Member
-
May 8th, 2006, 06:52 PM
#7
Re: Listview Error
In that case it could be the following:
Trim(Ret_Sql.Fields("TB02_NOME").Value)
-
May 8th, 2006, 06:56 PM
#8
Thread Starter
Fanatic Member
Re: Listview Error
When I put a constant String , eg "XXXX", too do not work
-
May 8th, 2006, 06:56 PM
#9
Re: Listview Error
Stupid question but you are creating the coulmns by running this code before the statement that is giving you the error?
VB Code:
' Add ColumnHeaders.
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 1", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 2", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 3", ListView1.Width / 3)
Also is the listview in Report View?
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
May 8th, 2006, 07:25 PM
#10
Re: Listview Error
 Originally Posted by mutley
When I put a constant String , eg "XXXX", too do not work
Are we familiar with words like
- Thank you
- Obrigado
- Gracias
- Merci
- Danke
- Спасибо
- Grazie
?..
-
May 8th, 2006, 07:28 PM
#11
Thread Starter
Fanatic Member
-
May 8th, 2006, 07:35 PM
#12
Thread Starter
Fanatic Member
Re: Listview Error
I am using as
Code:
Private Sub Form_Load()
...
....
Define_Listview
End Sub
Private Sub Define_Listview()
Dim clmX As ColumnHeader
Dim i As Integer
' With lvw_profissional
Set clmX = lvw_profissional.ColumnHeaders.Add(, , "Código")
Set clmX = lvw_profissional.ColumnHeaders.Add(, , "Profissional")
lvw_profissional.BorderStyle = ccFixedSingle ' Set BorderStyle property.
lvw_profissional.View = lvwReport
' Set itmX = lvw_profissional.ListItems.Add(, , 2)
' itmX.SubItems(1) = "xxxx"
End Sub
Private Sub Carregar_Funcionarios()
Dim LSql As String
Dim lInd As Integer
Dim itmX As ListItem
On Error GoTo CarregarFLUXOErro
Screen.MousePointer = vbHourglass
'lst_profissional.
cmb_profissional.Clear
LSql = "SELECT TB02_PK, "
LSql = LSql & " TB02_NOME "
LSql = LSql & " FROM TB02 "
LSql = LSql & " ORDER BY 2 "
Call Executar_Sql(LSql, Ret_Sql)
'cmb_Grupo.AddItem "{Nenhum}"
' cmb_Grupo.ItemData(cmb_Grupo.NewIndex) = 0
If Not (Ret_Sql Is Nothing) Then
While Not Ret_Sql.EOF
Set itmX = lvw_profissional.ListItems.Add(, ,Ret_Sql ("TB02_PK").Value)
i tmX.SubItems(1) = TrimRet_Sql ("TB02_NOME").Value)
cmb_profissional.AddItem Trim(Ret_Sql("TB02_NOME").Value)
cmb_profissional.ItemData(cmb_profissional.NewIndex) = Ret_Sql.Fields("TB02_PK")
Ret_Sql.MoveNext
Wend
Ret_Sql.Close
End If
Screen.MousePointer = vbNormal
Exit Sub
CarregarFLUXOErro:
Screen.MousePointer = vbNormal
'Call Tratar_Erro
End Sub
When I put constaants , too return me error
Thank you in advance
-
May 8th, 2006, 07:41 PM
#13
Re: Listview Error
I'm not sure what you mean but highlighted text (code) makes no sense - try replacing with the following:
VB Code:
Set itmX = lvw_profissional.ListItems.Add(, , Ret_Sql.[B]Fields[/B]("TB02_PK").Value)
tmX.SubItems(1) = Trim(Ret_Sql.[B]Fields[/B]("TB02_NOME").Value)
-
May 8th, 2006, 07:45 PM
#14
Thread Starter
Fanatic Member
Re: Listview Error
Hi
My work fine as:
Code:
Private Sub Carrega_Listview(Prs As ADODB.Recordset)
Dim itmX As ListItem
Set itmX = lvw_profissional.ListItems.Add(, , Prs("TB02_PK").Value)
'itmX.SubItems(1) = Trim(Prs("TB02_NOME").Value)
itmX.ListSubItems.Add , , Prs("TB02_NOME").Value
End Sub
Thank you
-
May 8th, 2006, 08:23 PM
#15
Re: Listview Error
You're welcome.
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
|