Solved

ListView

Posted on 2001-06-06
10
509 Views
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 ?
0
Comment
Question by:raed
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 49

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.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6159802
0
 
LVL 2

Accepted Solution

by:
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.

0
 

Expert Comment

by:GC04319
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)

GC04319
0
 
LVL 2

Expert Comment

by:Microsoft
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
'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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:raed
ID: 6170426
agriggs :

where from can i buy a good one ?
0
 

Expert Comment

by:qazafiq
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)

msfgrid.setfocus
0
 
LVL 2

Expert Comment

by:agriggs
ID: 6182100
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
 
LVL 5

Expert Comment

by:Netminder
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.

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
 
LVL 5

Expert Comment

by:Netminder
ID: 6821422
Force/accepted by

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now