Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Last Column Width In Listview (report View)


Hi,Does anyone know an easy way I can make the width of the LAST column header in a 'report view' listview automatically be equal to the space available.ie, if the other columns take up half the width of the listview, the last column takes up the other half.Similary, if the width of one of the other columns changes, the width of the last column is automatically changed appropiately (so there is never a horizontal scroll bar).Thanks in advance for any help you can give me.Tom.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Last Column Width In Listview (report View)
Hi,


Does anyone know an easy way I can make the width of the LAST column header in a 'report view' listview automatically be equal to the space available.


ie,

if the other columns take up half the width of the listview, the last column takes up the other half.


Similary, if the width of one of the other columns changes, the width of the last column is automatically changed appropiately (so there is never a horizontal scroll bar).


Thanks in advance for any help you can give me.


Tom.

How To Calculate Column Width In List View Based On Its Contents?
Hi All,

When a list view is filled with 6 col data such as invoice_no,invoice_date, currency, amount, cust_code, cust_name, the column widthremains same for all cols. But I would like to set the column widthbased on the max width of its contents.



Thanks & Regards
Balakumar*

Listview Column Width
Can someone show me how to set the column width in a Listview?


ListView1.View = lvwReport 'Set The Listview1 View so Columns/Headers can be viewed
ListView1.ColumnHeaders.Add , , "SCAC"
ListView1.ColumnHeaders.Add , , "Last Feed"

I can't get the above code to work when I add a width. The listview is blank when code is run.


I would appreciate any suggestions.

Thanks

Listview Column Width
How do you modify a listview's column width at run time?

Set Column Width In LISTVIEW
Hi,

The Listview have serveral columns and it is in List report mode.

Try to do the following by add the column text and width, but no matter how I put in the width parameter, the column width is not change. any idea.


.ColumnHeaders.Add text:="Flag", width:=20
.ColumnHeaders.Add text:="Customer Name", width:=150
.ColumnHeaders.Add text:="Contact", width:=250

Thanks!

Listview Column Width
Hi all,

I want to emulate or get the functionality of when you double click between two columnheaders in a listview, how they resize the column to maximise the width according to the column data. There is no event built in as far as i've seen. Has anyone got any idea how I can do it?

Basically i'm loading data into the listview in report view when i form load and I want the columns to be maximised for the data on form load as well.

Thanks in advance.

Column Width In ListView!
I have a ListView with 2 columns. I want the width of the 1st column to be 3500 but even after specifying 3500 as the width of the 1st column in the ListView's Property Page (which comes up when Custom property is clicked in the Properties window) under the Column Headers tab, the width always remains the default i.e. the width refuses to change to 3500. How do I resolve this issue?

In fact, changing the width of the 1st column just doesn't make any difference; it always remains the same.

The view of the ListView is set to lvwReport & the ListView doesn't display the GridLines.

Listview Last Column Width
Hi another simple one for you guys to help me with. Im using a listview and i thought there was a way to make the last colum automatically fill the whole of the remaing space.

Thanks

ListView Column Width
I can't get the Column Width in a ListView to size to my requirements. Anyone else have the same problem ? Any help would be appretiated.

ListView1.ColumnHeaders(1).Width = 1000
ListView1.ColumnHeaders(2).Width = 3000

No matter what value I set it to , I get the same width when the form displays !

Listview - Can Column Width Be Set
Can I set the column widths in the listview control so that they remain constant .. what about adding a scroll bar

Listview Column Width
Hi all,

I want to emulate or get the functionality of when you double click between two columnheaders in a listview, how they resize the column to maximise the width according to the column data. There is no event built in as far as i've seen. Has anyone got any idea how I can do it?

Basically i'm loading data into the listview in report view when i form load and I want the columns to be maximised for the data on form load as well.

Thanks in advance.

ListView Column Width Issue
I have 2 ListView Controls. I am using the lstColumns to show the column headers and lstTable for the table.

In my lstColumns_GotFocus event I have:

Code:
Private Sub lstColumns_GotFocus()
Dim N As Integer

For N = 1 To lstColumns.ColumnHeaders.Count
lstTable.ColumnHeaders(N).Width = lstColumns.ColumnHeaders(N).Width
Debug.Print "Status: " & lstTable.ColumnHeaders(N).Width, "Column: " & lstColumns.ColumnHeaders(N).Width
Next
lstTable.SetFocus

End Sub
My issue is the debug.print statement shows the column width in one control is the same for the other but the lstTable column width is actually wider.

Now before you ask why I use two ListView Controls when I could use one, well, think of this situation:

You have 100 records in the lstTable control and your GUI is showing the last 20 or so because you scrolled down to them. If you update the list the top most visible ListItem is the first record causing a undesirable jump from the bottom to the top.

So, after all this being said, here is my question:

1. How do I keep the scroll position locked on the ListView control during a update?

If you can answer #1 then never mind #2.

2. How do I make lstTable control column width match lstColumns control column width?

How To Change Width Of A Column In ListView?
How to configure width for each column in a list view instead of default fixed width?

Thanks.

Listview Column Width Lock
Is it possible to lock the width of the listview column to prevent the user from adjusting them at runtime?

How To Set Different Column Header Width Of ListView?
Hi ,
Let's assume i need to have 4 column headers in a List View report mode.
And each column header must have different width size, for each column.
How can i achieve that in coding?

Thanks, Sally

Column Width In ListView Element
How can I set the width of columns by source code programming ?

Regards
Zachi

Only Resize Certain Listview Column If It Is Greater Than Current Width
Hi Guys,

I am using the following code to resize listview columns according to their contents.


Code:
For Col2Adjust = 1 To Lv.ColumnHeaders.count - 1
If (Col2Adjust = 2) Then
Debug.Print Lv.ColumnHeaders(2).Width
If (Lv.ColumnHeaders(2).Width > 6423.875) Then
Call SendMessage(Lv.hWnd, _
LVM_SETCOLUMNWIDTH, _
Col2Adjust, _
ByVal LVSCW_AUTOSIZE_USEHEADER)
End If
Else
Call SendMessage(Lv.hWnd, _
LVM_SETCOLUMNWIDTH, _
Col2Adjust, _
ByVal LVSCW_AUTOSIZE_USEHEADER)
End If
Next


As you can see I want to skip column 2. I only want to resize column 2 if the width is greater than what I have specified there. But it isn't working.

Any ideas.

Listview: Restrict User From Resizing Column Width
I am using listview on my form.
I don't want to allow user to resize the column width of listview.

How can I do this? Please help and guide.

Determining The Required Column Width Of A ListView Control
Hello,

I use a ListView control (report view) to show the user a summary of error
messages. The width of the column that holds the error messages is such that
no horizontal scrollbar is needed. However, in some cases, the length of the
error message text is wider than the width of the column. In this case, the
text is hyphened with three dots.

I want to check the width of the error message text and if necessary,
increase the width of the ListView column. By trial and error, I know that
the amount of text that fits in a column of width 5620 twips is exactly
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX".

So, I created the following piece of code (the string Message holds a
certain error message):

With Printer

If .TextWidth(Message) >
..TextWidth("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") Then

ListView1.ColumnHeaders.Item(3).Width = .TextWidth(Message) /
..TextWidth("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") * 5620

End If

End With

Although this code functions properly, I don't think it's an outstanding
solution. Does somebody knows a better piece of code?

Thanks in advance,

Geert-Pieter

Forcing A Listview Column To Stay A Fixed Width
Does anyone know a way to force a listview column to stay a fixed width if a user attempts to resize it via its divider in the header control?

Help About ListView Report View
How can I add a new item to a particular column in report view? For example I have a columns named First and Second, I want to add an item to the Second column and not in First. Please tell me how. Please. Please. Please.

Listview - Report View With Icons?
Is it true that is you have the listview's view set to 3 (lvwReport) that it can't show icons?

I have a imagelist on a form with a picture in it. The picture has a key. I set the listview's icons and small icons to this imagelist. I tryed to add the picture to a listview menu item and used its key.

Didn't work. Any suggestions?

Listview + Report View + Colour
Can I make subitems have different backcolors or forecolors to them?

Right To Left ListView? (Report View)
I've tried implementing a right-aligned listview (comctl 6.0), but without any effect.
The listview is in report view mode.
Running WinXP. Shell language is Hebrew.

Code:
OldExStyle = GetWindowLong(lvwLearn.hWnd, GWL_EXSTYLE)
OldExStyle = SetWindowLong(lvwLearn.hWnd, GWL_EXSTYLE, OldExStyle _
Or WS_EX_LEFTSCROLLBAR Or WS_EX_RIGHT Or WS_EX_RTLREADING)
There is no apparent change to the listview, even though the call succeeds.

Does anyone have a solution?

ListView (Report View) Troubles...
I have a list view that can contain alot, a few, or no values at all at any given time.
The box will display existing information in row 1, then in row 2 it will display the information that will overwrite the existing information (if the user chooses). Then the 3rd will be existing, 4th new, 5th existing, 6th new, etc...

The grid goes in pairs, and the check boxes are turned on. By default nothing is checked. I want the user to be able to click whatever they choose, if they check the box on an odd row, then all the text in every cell of that row will go bold, and the entire row after that cell will lose its bold font (incase it was selected before). The rows look like this:

1 asdfas as as dasdfasf asdf
1 asdf asf asdf asdf asd fasf asd
2 asf asdf asdf asf asf asdf asdf
2 asf asd fasdf asd fasdf asdf asdf
3 asdf asdf asf asf asdf asdf asdf
3 asdf asdf adsf adsf as fasd
4 adsf asdf sdf asf sa dfas fasdf as
4 asdfasdfa sdf asdf as fafs

Of course with check boxes to the left of the numbers, if i click the 2 on the bottom, it will go bold and the 2 above it will be unchecked and go back to non-bold font. I know this is possible, im pretty close already.. Here's what i have:


Code:
Private Sub lvConflicts_ItemCheck(ByVal Item As MSComctlLib.ListItem)
Dim MyCount As Integer
If Item.Checked = True Then
Item.Bold = True
For MyCount = 1 To 8
Item.ListSubItems.Item(MyCount).Bold = True
Select Case Right(Item.Index, 1)
Case Is = 1, 3, 5, 7, 9
Item.ListSubItems.Item(MyCount).ForeColor = vbBlack
lvConflicts.ListItems(Item.Index + 1).ForeColor = &H808080
lvConflicts.ListItems(Item.Index + 1).Checked = False
Case Is = 0, 2, 4, 6, 8
Item.ListSubItems.Item(MyCount).ForeColor = vbBlack
lvConflicts.ListItems(Item.Index - 1).ForeColor = &H808080
lvConflicts.ListItems(Item.Index - 1).Checked = False
End Select
Next MyCount
Else
Item.Bold = False
For MyCount = 1 To 8
Item.ListSubItems.Item(MyCount).Bold = False
Select Case Right(Item.Index, 1)
Case Is = 1, 3, 5, 7, 9
Item.ListSubItems.Item(MyCount).ForeColor = vbBlack
lvConflicts.ListItems(Item.Index + 1).ForeColor = &H808080
Case Is = 0, 2, 4, 6, 8
Item.ListSubItems.Item(MyCount).ForeColor = vbBlack
lvConflicts.ListItems(Item.Index - 1).ForeColor = &H808080
End Select
Next MyCount
End If
End Sub


Im practically doing it already, i know it.. I think im just thinking too hard.. ive been working too long on this

Listview (report View) Scrollbars
I can't seem to figure this out: how do I add vertical and horizontal scroll bars to a Listview control with its "View" property set to "lvwReport"? I have tried many thing ... but none seem to work.

Icons In Listview In Report View
Hi, I am having trouble trying to display icons in a listview. I am displaying the listview in report mode and I have all the imagelists properly bound. If im not mistaken, the icons used in the report view use the 'small' imagelist, correct? Anyway I am populating the imagelist by creating a ListItem variable and setting it to Listview1.Add each time through the loop. Could this be the problem?

Data Report In Vb6|error:report Width Is Greater Than Page Width|what Can I Do?
i am building my report on vb6 data report. i have to make a wide report since i have so many fields to accomodate. but when i try to run the app. it says the report width is greater than the page width. how can i get over this situation.
i switched over to vb6 data report because..
( i tried making reports on crystal reports 8.5 but i can adjust so many fields on the single report even after changing the page setup to landscape instead of portrait.)
can't i make bigger reports? please help.

Data Report In Vb6|error:report Width Is Greater Than Page Width|what Can I Do?
i am building my report on vb6 data report. i have to make a wide report since i have so many fields to accomodate. but when i try to run the app. it says the report width is greater than the page width. how can i get over this situation.
i switched over to vb6 data report because..
( i tried making reports on crystal reports 8.5 but i can't adjust so many fields on the single report even after changing the page setup to landscape instead of portrait.)
can't i make bigger reports? please help.

ListView Column Header Width - "Autosize"???
I'm curious to know if "after" a listview has been populated with all the columns and data if there is a way to "Autofit" the column widths, like Excel can do.

It SURE would make life a lot easier.

Moving Columns On A Listview (Report View)
I want to programmatically set the Position of the columns in a list view.

This is an "after thought" so I am trying to do it on already loaded listviews.


I see from a little experimentation that I can easily move the column headers by simply changing the .position property.

But that does not bring over the data for that column. (Just the header)

Do I have to manually move the data or there an easier way?


(By "manually move the data" I mean set up a temp array, copy the column's data, update new column after moving other column into original col number)


Regards,

ListView Report Mode View - RESOLVED
When I change to report mode view nothing is showing up in my listview. When I change it to List view my data shows up. Any ideas?


VB Code:
Private Sub LoadTableSpecs()        Dim oSQLServer As New SQLDMO.SQLServer    Dim oSQLDatabase As New SQLDMO.Database    Dim oSQLTable As New SQLDMO.Table    Dim oSQLColumn As New SQLDMO.Column        Dim i As Integer    Dim liObject As ListItem        ListView1.ListItems.Clear        oSQLServer.LoginSecure = True    oSQLServer.Connect Form1.cboServer1.Text    Set oSQLDatabase = oSQLServer.Databases(Form1.cboDatabase1.Text)    Set oSQLTable = oSQLDatabase.Tables(Form1.cboTable1.Text)        For Each oSQLColumn In oSQLTable.Columns                Set liObject = ListView1.ListItems.Add(, , oSQLColumn.Name)        liObject.SubItems.Add , , oSQLColumn.Datatype        liObject.SubItems.Add , , oSQLColumn.Length        Set liObject = Nothin        Next    oSQLServer.DisConnectSet oSQLServer = NothingEnd Sub

ListView (Report View) - Adding Items
AH! This is embarassing yet very frustrating. The last time I worked with the list view control was a loooong time ago. Unfortunately, I lost that project when my computer crashed (no big deal really, the program was never even completed). At any rate, how the heck do I add subitems and items to a report view listview?!

eg
Column 1 Column 2
Add Item Add Item
Add Item Add Item

ListView (Report View) Numeric Sorting
Hi,

I have a listview control in report view, and I have it so that when I click on a columnheader it sorts the list items by that column, the problem is that when I do that on a numeric column its sorts it like this

1
11
2
3
3100
4
...

I was wondering how can I make it so it sorts the column correctly

1
2
3
4
11
3100

Let me know if you know a way

Thanks In Advance,

Zmei



Edited by - Zmei2004 on 8/29/2004 8:45:42 AM

How To Add A Thumbnail To A ListView Subitems That Will View In Report Format?
How to add a thumbnail to a ListView subitems that will view in report format?

Editing Selected Item In ListView In Report View
How can I edit the second column of data in a listview control? I am making a properties box much like the one you use in VB. The first column information for each item can not be editable but the second column is going to be the value for each item and I need for it to be able to click and type in it just like in VB (or at least similar to that).

Any help and sample code is appreciated. Thanks.

*solved*I Wanna Learn ListView In Report View
hi this is a new thread after advice on moving from Picture1 to now i believe ListView in Report view is the way to go.

Metallisoft can you help me get his going. I have attached form1 to download and change as i can't get it to work. your reference click here hasnt helped me as it gave me 3 values i only need 2

Database eg
Quote:UNIVERSAL    OEM    MFG
16190    2-1428-HI    WAI
16190    SJ-0001R    AIM
16190    91-25-1030    WILSON
16190    S9024    LUCAS REMAN
16190    9821006350    ISUZU
16190    9821006060    ISUZU
16190    S114-136    HITACHI
16190    S114-100    HITACHI
16190    SR198X    BOSCH REMAN
16190    94022494    GENERAL MOTORS
16190    RXS056    OEX
16190    94021044    GENERAL MOTORS
16190    S114-118    HITACHI I Don't need to display the UNIVERSAL Numbers Just OEM anf MFG only

Code:Private Sub Command3_Click()
Set rs = New ADODB.Recordset 'this will be the rs
Dim strSQL As String 'this the source
         
'make the selection string: filter the records right away
strSQL = "SELECT C.* FROM OEMS AS C where UNIVERSAL in(select UNIVERSAL from OEMS where oem='" & UCase$(Text1) & "')"
                       
' To hold a reference to the current Listitem (row).
Dim oLVItem As MSComctlLib.ListItem

' The (Listview.Width - 350) / 3 simply adjusts the column
' widths to 1/3 the width of the Listview (subtracting the
' width of the scrollbar)
' ListView.ColumnHeaders.Add , , "Supplier", (ListView.Width - 350) / 3 '<- Don't need to work?
ListView.ColumnHeaders.Add , , "OEM", (ListView.Width - 350) / 3
ListView.ColumnHeaders.Add , , "Manufacturer", (ListView.Width - 350) / 3

        
        
        Picture1.Cls
        Picture1.FontSize = 8
        Picture1.Font.Bold = True
        Picture1.Print ">> Supplier Information"
        Picture1.Font.Bold = False
        Picture1.Print "OEM:"; Tab(20); "Manufacturer:"

    rs.Open strSQL, oConnection, adOpenStatic, adLockOptimistic, adCmdText
     
'loop through the recordset
    Do Until rs.EOF
        M19 = rs("OEM") 'Are m19 and m20 properties or local variables? didn't want to take them out, but if they are global settings and there are more records, they will only 'remember' the values in the last record.(No they are strings in a database)
        M20 = rs("MFG")
     
        Picture1.Print M19; Tab(20); M20
        rs.MoveNext
    Loop
     
    rs.Close 'Close the recordset never leave it open!
    Set rs = Nothing 'clear the rs variable

End Sub
  OK NOW how do i replace the Picture1 to ListView in Report view after reading MSDN click here CAN anyone save me? the ColumnHeaders don't display too?





Edited by - Hopeless on 6/4/2004 12:16:16 AM

ListView Control. How Do You Extractupdate Values In Report View
I have populated my ListView control with my values using DAO. I have 10 columns set up in report view. In my code fragment below, I am looking through my listview control searching for rows that the user has selected. Now I need to be able to extract some of the sub values and update others. How do I do this? Here is my code so far.

Private Sub SelectedCountCommand_Click()
Dim i As Integer

For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Selected = True Then
'extract values from col 3 and 4 and subtract them

'update column 5 based on the results of col 3 minus col 4

End If
Next

End Sub

Sorting ListView In Report Mode...(more Than One Column)
Hi,
I was looking for a way to sort the content of the items that I have in a listview...

let's say something like:

Code:
Product Exp. Date Price

Bread 08/23/2002 0.25
Bread 08/28/2002 0.25
Milk 09/01/2002 1.00
Milk 09/05/2002 1.00


note that the sorting is name of the product & exp. date with the exp. date in asc as the name of the product is...

when I load the listview...I have no problem at all I just sort the recordset on the name of the product & the exp. date...and I have the ListView filled just the way I want... the problem comes when I move the products to another ListView there the products can be sorted only by one of this...name of the product or by exp. date but not by the two of them...

does anyone knows a workaround on this?
(the problem comes when i return the products from one listview to another and when moved in random order...

Thanks!

Help: How To View Selected Items From Listview With Crystal Report Viewer
Hi

I have a Listview with check boxes from it want to view selected items with crystal report viewer.

Private Sub cmdView_Click()
Dim lCustomerId as Long
    Dim tmpItm As ListItem
    For Each tmpItm In lstItems.ListItems
        If tmpItm.Checked = True Then
            lCustomerId = Val(Replace(tmpItm.Key, "C", ""))
          End If
    Next

  End Sub

Plz. help

regards

MSFlexgrid - Set Column Width To Text Width..
How do I set the column width to be = to the amount of text

(the text length varies)

Changing The Column Width To The Longest Text In A Column With The MSFlexGrid Control
hi all how do i change the width of a column to fit the text inside that column i am using the MSFlexGrid to show my data, with an adodb conenction
thanks from
mark

How To Populate A ListView From A DB Adding Column Headings In Report Style?
I'm currently using ADO to connect to my DB. I want to populate a ListView(Report)with data from a table chosen from a CommonDial. but i don' know how to assign the ColumnHeadings as well as add the data. I want my program to be able to file out all the info in the ListView automaticaly once opened.(Tables I no nothing about?!?)

How To Change Background Color Of Column Header Of Listview In Report Mode?
how can we change listview's columnheaders' backcolor a?
thanks

saracjl

Sabin Kumar Chhetri

Error In Data Report(VB6) "Report Width Larger Than Paper Width"
I am suppose to generate a Data report in VB6..
but i am geting an error like 'Report width larger than paper width'
my data report width is 10000
i have also tried it by reducing it to 8000
but still geeting the same error......
is it because of the few large datafields in the report....

please tell me the solution...i needit urgently

 

Data Report - Paper Width Is Larger Than Printer Width
I am using the data report for my app which is running in several machines. I am getting an error "Paper width is larger than printer width" in only one machine. What may be the problem ?

Thanks.

Report Width Larger Than Paper Width Error In Datareport
I have to print a report (datareport), there is a predefined certificate on which I have to print my report

problem is, the certificate is a bit wide...and i am getting "report width larger than paper width error"

 i have dragged the scale (width) to 8.1 or 8.2, beyond that if i drag, i am getting the error


  i have set the datareport properties leftmargin, rightmargin, topmargin and bottommargin as 0.

  i have increased the reportwidth property value, still no use


  i want to increase the width of my report, (scale > 8.5), how to do it?


Srikanth

Error: Report Width Is Larger Than The Paper Width
i create few reports using Data Environment & Data Report. the reports r in A4 size (portrait), and some r in A4 size (landscape). when display the report which is portrait, it has no error. but when display the report which is landscape, an error says 'Report width is larger than the paper width'.

to display the landscape report, i must goto printer setting and set the paper orientation to landscape. then all my report can display.
BUT, the height of the portrait report is shorter. i mean the bottom of the portrait report will be blank (4 inch from bottom is blank)

i try to change the orientation before i open&display the report, but it doesnt work.
how to change the orientation, and the paper? pls help. Thanks.

Report Width Larger Than The Paper Width ERROR
Hi ,
I am using data reports for getting some reports from my application.While displaying or printing my reports, I get an error saying 'Report width is larger than the paper width.'
Now irrespective of the paper width settings of the printer I want that when I use the application at my client side, it should adjust the paper settings and printer settings so as to show and print the report.
Can anyone help me out on this....I have very little time at hand...and its ticking away...tick..tick...tick.....Help me


Thanks in advance.......

Copyright © 2005-08 www.BigResource.com, All rights reserved