Solved

Urgent question: Listview with checkboxes / column width

Posted on 2004-10-04
8
227 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 33

Expert Comment

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

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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 33

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

707 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

21 Experts available now in Live!

Get 1:1 Help Now