Solved

Urgent question: Listview with checkboxes / column width

Posted on 2004-10-04
8
255 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

839 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