Solved

Urgent question: Listview with checkboxes / column width

Posted on 2004-10-04
8
259 Views
Last Modified: 2011-09-20
Hi Experts,

I have a listview with checkboxes and one additional column holding text information. The column for the checkboxes is too small, the checkboxes appear too close to the text.

Is it possible to make the checkbox-column wider?

broesi
0
Comment
Question by:broesi
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 12219409
ListView1.ColumnHeader(1).Width=300    
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 12219436
Clicked submit button to soon.

You can adjust column width in FormLoad event.  Change 300 to whatever seems to work for you.  

ListView1.ColumnHeader(2).Width=?  would set width of the second column and so fort.

Mike
0
 
LVL 5

Author Comment

by:broesi
ID: 12220256
Hm,

the listview only has one column, and that contains the text data!?

Here's the code used to populate the list:

Private Sub Form_Load()
    Dim rs As ADODB.Recordset
    Dim li As ListItem
   
     Set rs = gDB.getRecordset("select MyText from tblMyTable"
   
    lv.ColumnHeaders.Add , , "Text", 5000
   
    Do While Not rs.EOF
        Set li = lv.ListItems.Add()
        li.Text = rs(0)
        rs.MoveNext
    Loop
End Sub

When I set a breakpoint at th do while... lv.columnheaders.count is 1


broesi
0
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!

 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 250 total points
ID: 12221302
The checkbox is part of the first column along with the text. These ARE NOT to different columns. So you cannot control the location of the text and how far it is from the checkbox. However, there is a wlakaround:

Private Sub Form_Load()
    Dim rs As ADODB.Recordset
    Dim li As ListItem
   
     Set rs = gDB.getRecordset("select MyText from tblMyTable"

'======================
    lv.View = lvwReport     'to add columns you must set to reports
    lv.FullRowSelect = True
    lv.HideColumnHeaders = True
    lv.ColumnHeaders.Add , , , 400    'first column. this one has the checkbox, modify width as you want
    lv.ColumnHeaders.Add , , Text    'add a second column
  '======================

    Set li = lv.ListItems.Add()
        li.SubItems(1) = "Text"       'to add text to second column
   
    Do While Not rs.EOF
        Set li = lv.ListItems.Add()
        li.Text = rs(0)
        rs.MoveNext
    Loop
End Sub

S
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 12223376
Hi broesi,

All I know about List View, I have learned from Shauli.  I am greatfull we have an expert like Shauli at EE.  His response is more complete and to the point.  

Regards,

Mike
0
 
LVL 3

Accepted Solution

by:
Noel_Castillo earned 250 total points
ID: 12223578
Heres another work around to set the distance of the text from the checkbox.
Precede ur text string with spaces during assignment.

Do While Not rs.EOF
        Set li = lv.ListItems.Add()
        li.Text = "     " & rs(0)                              '# of spaces depends on how far you want it to be
        rs.MoveNext
Loop

'it will also eliminate runtime error caused by null value in ur recordset (just in case)
0
 
LVL 5

Author Comment

by:broesi
ID: 12235847
Thanks a lot, guys! I've split the point, because I used Noel's suggestion and Shauli gave a good explanation of what's actually going on - is that okay with you?

broesi
0
 
LVL 3

Expert Comment

by:Noel_Castillo
ID: 12274179
Im glad that you use that simple idea. the split was ok with me. actually, that is my 1st points earned here. but by just knowing that the code helps you makes me feel good. im happy. tnx. :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 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