[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

ListView

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 ?
0
raed
Asked:
raed
  • 2
  • 2
  • 2
  • +4
1 Solution
 
Ryan ChongCommented:
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.
0
 
Ryan ChongCommented:
0
 
agriggsCommented:
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.

0
Industry Leaders: 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!

 
GC04319Commented:
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)

GC04319
0
 
MicrosoftCommented:
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
'parameter.
'-----------------------------------------------------------

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
        .Clear
        For i = 0 To UBound(TitlesAndWidths) - 1 Step 2
        .Add , , TitlesAndWidths(i), (TitlesAndWidths(i + 1) _
             * Width) / 100
        Next i
    End With
   
    Exit Sub
   
   
ErrorHandler:
    MsgBox Err.Description & "."
End Sub


IT MIGHT HELP OR POINT YOU IN THE RIGHT DIRECTION UNLESS IVE MIS READ THE QUESTION


cheers A

Andy

0
 
raedAuthor Commented:
agriggs :

where from can i buy a good one ?
0
 
qazafiqCommented:
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)

msfgrid.setfocus
0
 
agriggsCommented:
Sorry, raed, I missed the email.  You can start at www.vbxtras.com

You should be able to download an evaluation copy of True DB Grid from www.componentone.com.

0
 
NetminderCommented:
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.

raed,

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.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20261025
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20253068
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20193883
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20193880
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20193879
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20193268
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20174535
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20137815
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20130736

Thanks,

Netminder
Community Support Moderator
Experts Exchange
0
 
NetminderCommented:
Force/accepted by

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now