Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Urgent question: Listview with checkboxes / column width

Posted on 2004-10-04
8
Medium Priority
?
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 1000 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 1000 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Suggested Courses

636 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