Results 1 to 7 of 7

Thread: [RESOLVED] Print listview column header

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Print listview column header

    I would like to know, How I can print listview column header? I cannot print the column header. Why? what wrong with this code?

    Code:
    'column header
    For i = 1 To Form5.ListView2.ColumnHeaders.Count
    Printer.Print Tab(5); Form5.ListView2.ColumnHeaders(1); _
                           Tab(25); Form5.ListView2.ColumnHeaders(2); _
                           Tab(45); Form5.ListView2.ColumnHeaders(3); _
                           Tab(65); Form5.ListView2.ColumnHeaders(4); _
                           Tab(85); Form5.ListView2.ColumnHeaders(5); _
                           Tab(105); Form5.ListView2.ColumnHeaders(6); _
                           Tab(125); Form5.ListView2.ColumnHeaders(7); _
                           Tab(145); Form5.ListView2.ColumnHeaders(8);
    Next

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Print listview column header

    try this statement...
    vb Code:
    1. Printer.Print Tab(5); Form5.ListView2.ColumnHeaders(1).Text; _
    2.                        Tab(25); Form5.ListView2.ColumnHeaders(2).Text; _
    3.                        Tab(45); Form5.ListView2.ColumnHeaders(3).Text; _
    4.                        Tab(65); Form5.ListView2.ColumnHeaders(4).Text; _
    5.                        Tab(85); Form5.ListView2.ColumnHeaders(5).Text; _
    6.                        Tab(105); Form5.ListView2.ColumnHeaders(6).Text; _
    7.                        Tab(125); Form5.ListView2.ColumnHeaders(7).Text; _
    8.                        Tab(145); Form5.ListView2.ColumnHeaders(8).Text;
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Print listview column header

    Thank you it work. But I would like to know, How I can print all column header in the listview without specific the number. Some thing like this

    For i = 1 To Form5.ListView2.ColumnHeaders.Count How to do that?

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Print listview column header

    vb Code:
    1. Dim i As Integer, iTab As Integer
    2. iTab = 5
    3. For i = 1 To Form5.ListView2.ColumnHeaders.Count -1
    4.     iTab = iTab + 20
    5.     Printer.Print Form5.ListView2.ColumnHeaders(i).Text & Tab(iTab) ;
    6. Next
    7. Printer.EndDoc
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Print listview column header

    What the purpose of this code?

    iTab = iTab + 20

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Print listview column header

    I made some modification. It works

    Code:
    Dim i As Integer, iTab As Integer
    iTab = 5
    For i = 1 To Form5.ListView2.ColumnHeaders.Count - 1
    Printer.Print Tab(iTab); Form5.ListView2.ColumnHeaders(i).Text;
    iTab = iTab + 20
    Next

  7. #7
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: [RESOLVED] Print listview column header

    Quote Originally Posted by matrik02
    What the purpose of this code?

    iTab = iTab + 20
    you are going to print all the column headers thru a loop and you need to specify the positions...instead of hardcoding the tab values in individual statements I put a variable which can do this..
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width