Solved

Urgent question: Listview with checkboxes / column width

Posted on 2004-10-04
8
238 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 85
vb6 connector to SQL Server 2 34
Spell Check in VB6 13 99
Create Files based on Cell Values in a Range in Excel 12 21
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

863 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

27 Experts available now in Live!

Get 1:1 Help Now