Posted on 2001-06-06
Last Modified: 2009-07-29
i am using a listview i want to be able to change the values inside the list i mean i want to write in the column i want and the row i want ( can i ? )
i m thinking to use it as areplace to datagrid control.
is there a good sample on using the datagrid or MSflixgrid as adetail in a form with powerfully dealing with rows and columns , can i set the focus on acetain row,column ?
Question by:raed
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
LVL 52

Expert Comment

by:Ryan Chong
ID: 6159735
Hi, Listview control is only allow one column (head - usually first column of listview) , when its LabelEdit property set to 0 - lvwAutomatic.

If you want to set focus on certain column and row, and due with database , then Datagrid control can be used.
LVL 52

Expert Comment

by:Ryan Chong
ID: 6159802

Accepted Solution

agriggs earned 200 total points
ID: 6160078
If what you want to do is to allow the user to type directly in the Listview and edit the various columns, then no, you cannot do that (with the exception of the first column, if the LabelEdit property is set to automatic as above.)

For that purpose, I have had good luck with True DB Grid, but it costs money.

Of course, you can set the values of the various columns in the listview in your VB code.  You do this by using the listview style of lvwReport.  Then each ListItem object will have a property called SubItems.  The SubItems property is a collection of strings, that you can set each one by using an index into the collection.

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.


Expert Comment

ID: 6160637
in MSDN, you can find an topic "msflexgrid tips and trics" explaining how to implement an editable/sortable grid (a combination of msflexgrid and an textbox)

the code in the topic is very to the point.

the briefly discuss the differnce between the dbgrid and the msflexgrid (which probably is a better choice than the listview)


Expert Comment

ID: 6161016
try this matey

'NOTE: You must include this procedure within a form
'      And the listview control is named ListView1
'      by Default.  It's easy enough to adjust the code
'      for your own needs (e.g., change ListView1 to the
'      the name of your List View, or rewrite the function
'      to accept the ListView control as a parameter

'Each PercentWidth value, (an integer), is the percent of the
'ListView box's width that is to be assigned to the column.

'If the total of the PercentWidth values exceed 100, the box will
'have a horizontal scrollbar.

'If the total is less than 100, an unusable section of the
'title area will be present in the ListView box.  If your
'data includes the need to scroll vertically, you might size
'your columns in such a way as to leave room for the vertical
'scrollbar.  Leaving room'for a scrollbar isn't mandatory.

'Author's Notes:
'This code assumes zero-based array-indexing.  If you're
'using 1-based indexing, make the necessary adjustments
'to and within the For-loop and to the parameter-check code.
'While the code works as-is, including its error-handling,
'you should adapt its error
'handling to your own requirements.
'After debugging, if all of your calls to this procedure are
'hard-coded and aren't under software-control, the
'parameter-check may be removed.  However, if your code
'constructs an indeterminate number of titles for the box,
'you may wish to incorporate the parameter-check into your
'error-handling scheme.
'The "80" is an "adjustment" factor.  When using the VB5 ListBox,
'change the value from "80" to 850.  Without it, specifying 100
'as the total for the various widths always includes a scrollbar
'in the ListView box.  That's not nice.

'Troubleshooting Problems With Input-Parameters
'Input Parameters               Result
' "First", 30                   "First" occupies 30% of the
'                                box's width. The remainder is
'                               an inactive (blank) title bar.
' "First", 30, "Second"         After display of the parameter-
'                               check error message,the
'                               display is the same as the
'                               previous sample.
' "First", "Second"             "Type Mismatch" error.  "Second"
'                               is a string and it should
'                               have been an integer.
' 40, "First"                   "Type Mismatch" error.  The
'                                parameters are reversed.  An
'                               integer should be first,
'                                followed by a string.
' "First", 40, 40               See second example.

'When presented with an odd-number of titles and widths, the
'procedure displays each pair and entirely omits the last

Public Sub AddColumnsToViewBox(ParamArray TitlesAndWidths())
    Dim i, Width, ParameterCount, Msg

    On Error GoTo ErrorHandler
    ListView1.View = lvwReport
    'Input-parameter check. (See Author's Note)
    ParameterCount = UBound(TitlesAndWidths) + 1
    If ParameterCount / 2 <> CInt(ParameterCount / 2) Then
       Msg = "Input-parameter count is incorrect.  You must " & _
              "specify an equal number of titles and widths."
        MsgBox Msg, , "Prameter-Count Error"
    End If
    Width = ListView1.Width - 80
    With ListView1.ColumnHeaders
        For i = 0 To UBound(TitlesAndWidths) - 1 Step 2
        .Add , , TitlesAndWidths(i), (TitlesAndWidths(i + 1) _
             * Width) / 100
        Next i
    End With
    Exit Sub
    MsgBox Err.Description & "."
End Sub


cheers A



Author Comment

ID: 6170426
agriggs :

where from can i buy a good one ?

Expert Comment

ID: 6180567
yes you can set the focus on a particular column and row in a grid.

just say

msfgrid.row = (what ever you want)
msfgrid.col = (what ever you want)


Expert Comment

ID: 6182100
Sorry, raed, I missed the email.  You can start at

You should be able to download an evaluation copy of True DB Grid from


Expert Comment

ID: 6767440
There has been no activity in this question in quite some time, and it looks like it has been abandoned. As part of our ongoing mission to clean up the topic areas, a Moderator will finalize this question within the next seven (7) days. At that time, either I or one of the other Moderators will force/accept the comment of agriggs.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.


Some of these questions have been open for some time, and records indicate you logged in as recently as this week. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days.


Community Support Moderator
Experts Exchange

Expert Comment

ID: 6821422
Force/accepted by

Community Support Moderator
Experts Exchange

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question