Resizing Columns In One Listview To Automatically Resize Corresponding Columns In Another.
I'm currently building the front end to a VB6 application. This app is largely based on entering data into a Listview. In order facilitate data entry, I need to create an editable row beneath the listview, comprising of text boxes(unless there is a better method) and an "add" button. The problem is that when a column in the Listview is moved or resized, the array of textboxes need to reflect this change of order/size, as each textbox needs to appear beneath its corresponding column. Also, if the listview contains a large number of columns, and therefore a horizontal scrollbar, the textboxes will need to scroll also... I would be very grateful for any help..! Thanks...
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
ListView: Resize Columns Automatically
Hi all!
Two days of reading things about rescaling the colWidht of colums in a ListView (report) and I still don't get it.....
Now I've done this:
Code:
Private Sub Form_Resize()
Dim colWidth
Dim LVSCW_AUTOSIZE, colWidth As Long
LogBox.Width = SW - 750
LogBox.Height = SH - 2500
colWidth = Me.LogBox.Width - 1000
LVSCW_AUTOSIZE = -1
With LogBox
Call SendMessage(.hWnd, 150, 1, LVSCW_AUTOSIZE)
Call SendMessage(.hWnd, 150, 2, LVSCW_AUTOSIZE)
Call SendMessage(.hWnd, 150, 3, LVSCW_AUTOSIZE)
Call SendMessage(.hWnd, 150, 6, LVSCW_AUTOSIZE)
Call SendMessage(.hWnd, 400, 7, LVSCW_AUTOSIZE)
Call SendMessage(.hWnd, colWidth, 4, LVSCW_AUTOSIZE)
Call SendMessage(.hWnd, colWidth, 5, LVSCW_AUTOSIZE)
End With
End Sub
Only colums 4 and 5 should change their size according to the size of the listview "LogBox".
The calculated values are correct, but there is no change of columnsize to be seen (this time it really isn't )
Jeannette
Resizing Datagrid Columns Automatically
Hi,
How would you resize the columns of a datagrid to be the size of the largest word in that column automatically when data is added to the datagrid.
Any example code out there, or links to tutorial for this problem would be great.
Thanks
Resizing Columns In A ListView
This is related to my earlier post about invisible columns.
I'd like to know if individual columns can be specified as resizable / non-resizable or if the property must necessarily apply to all the columns...
Resizing Listview Columns
Hello,
Is there any way to programically resize the columns of the Listview control with out the Column Header?
Resize Columns In A MSFlexgrid And A Listview
I have been using this code by Mark Gambo in this thread - thanks Mark
The problem I now have is trying to get the columns in my Flexgrid and a number of listviews to resize in proportion to the form resize.
Do people prefer to just disable the resizing of these controls or do they go with the column resizing?
Does anybody have any ideas about this.
My forms with these controls on are ChildForms of my MDI form.
Thanks
Resizing The Columns In Listview Control
Hi,
Is it possible to resize the columns in listview based on the content of
column?
Regards,
Subbu S
This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information.
If you are not the intended recipient, please contact the sender by reply
e-mail and destroy all copies of the original message.
Any unauthorized review, use, disclosure, dissemination, forwarding,
printing or copying of this email or any action taken in reliance on this
e-mail is strictly
prohibited and may be unlawful.
Adding Columns To A Listview That Already Has Columns
Hi
I'm new to VB6 (I usually program in VB.NET but have been asked to make an enhancement to a VB6 application).
I have a listview which has columns defined within it in the designer. The code I am looking at then retrieves data from a db and puts it into the listview.
I've been asked to add another column in the middle of the listview e.g. there are 10 columns defined in the designer and this new column needs to go at position 6. However, the data that needs to go in the new column needs to come from a different query than the one that fills the other columns. I therefore thought that the best way to do it was fill up the original columns and then slot in the new column and fill it from another query. I've been searching around but can't find any example of how to do this.
Please can anyone help, or suggest a better way to do it? Thanks!
Automatically Arranging Columns
Helle there,
Would anyone be able t help me with this little dilemma that I have.
I am trying to create some code which automates the sorting of my columns from left to right in decending order based on the totals from greatest to least.
Here is an unsorted sample:
Iiiiiiiiiiiiiii
a193177
b2104188
c3115199
d41262010
e51372111
f61482212
g71592313
h816102414
I917112515
j1018122616
Total5513575215115
Here is the required result:
iiiiiiiiiiiiiiI
a179731
b1810842
c1911953
d20121064
e21131175
f22141286
g23151397
h241614108
I251715119
j2618161210
Total2151351157555
I apprecitate your help.
Resize Datagrid Columns....
Is there a way to autosize Data grid columns to the text that is in them?
Similar to the way it can be done in a listview......
HSHFlexGrid Columns Resize
Heys everyone
i was wondering i have a MSHFlexGrid that is getting data from a database via ADO. Can anyone tell me how to get the columns to resize the the largest entry in that column?
Frosty
DataGrid - Resize (not Columns) - Help Please
Hi,
I am trying to resize my datagrid on screen, so when you change the size of the form, everything expands to fill it. This is all fine except the horizontal movement of the datagrid, the vertical expansion is fine (i.e. always keeps 120 distance from the bottom). All my other code works fine!
Thanks in advance for your help.
Paul.
VB6/W2K
MSFlexgrid - Resizing Columns
Does anyone know a way to resize a column in MSFlexgrid to a different value than the default? Basically, I have want to override the default settings that MSFlexgrid uses for column widths.
I have the following code:
.
.
mf1.Col = 4
mf1.Text = "Activity"
.
.
adding something like mf1.colwidth = 1000 doesn't work, gives back a "Compile Error: Argument not optional" message.
Any help appreciated. Thanks.
Resizing Columns Using Vb In Excel
Ok this is probably pretty easy but I don't have the help files installed on my computer so I can't do it myself...
I have a spreadsheet that is locked where people enter information, but i have one column that is hidden (it has employee wages in it) but if someone needs to adjust these wages then i want them to be able to click a button which will adjust the width of the column if it's hidden and hide it when it isn't hidden. (so they click once to show and once to hide) i know how to unlock and relock the worksheet, i just need help changing the width of the column. also i'd like to add an alert (like "Please click this button again to hide wages column after adjustments are made").
i am just using the VB which comes with excel premium. thanks in advance
Resizing Columns With For Each Statement
How do I resize all columns in listview object by setting colX as a columnheader and then for each columnheader setting the width with 'columnheader.width = listview1.width / listview1.columnheaders.count'
The problem is that i can't get the column objects right.
Resizing DataGrid Columns
I have a DataGris (as you may already know ), and would like to resize the columns to fit the text.
I wrote the following two routines, one that gets the widths according to the longest field in the recordset, and the other one that actually changes the sizes of the columns using the widths obtained from the other routine.
Nothing happens!!!!
Can someone please enlighten me ?
Code:
Public Function GetColWidths(ByVal grid As DataGrid) As Integer()
Dim Rowdatag, curRow, L, MyCols As Integer
Dim Myarray(20) As Integer
For Rowdatag = 0 To grid.VisibleRows - 2
curRow = grid.RowBookmark(Rowdatag)
For MyCols = 0 To grid.Columns.Count - 1
L = Len(grid.Columns(MyCols).CellText(curRow))
If Myarray(MyCols) < L Then
Myarray(MyCols) = L + 5
End If
Next MyCols
Next Rowdatag
GetColWidths = Myarray()
End Function
Public Function ResizeCols(ByVal grid As DataGrid, Myarray() As Integer)
Dim i As Integer
For i = 0 To grid.Columns.Count - 1
grid.Columns(i).AllowSizing = True
grid.Columns(i).Width = Myarray(i)
Next i
grid.Refresh
End Function
Then my call to the function is Code:Call ResizeCols(DataGrid1, GetColWidths(DataGrid1))
Auto Resize Flexgrid Columns
Just a quick question.
I am trying to find a way to auto resize the column widths in an MSHFlexgrid so that all the text in the field is shown. I have it so that the user can resize them, but i would idealy like them to auto resize.
Any ideas?
Thanks,
Sam
Resize MSFlexGrid Columns With Slider
I have an MSFlexGrid that I need to resize the columns on. I have a Slider, and it works.
Problem is this: The width does not change until I let go of the Slider. I'd like to see the width change smoothly as I was adjusting the Slider.
Anyone know how to do this?
Resizing Excel Columns That Are Too Narrow
Is it possible to only resize columns in excel that are too narrow. ie the ones with ##### displayed without having to search each cell. The auto fit function will shrink those that shouldn't be leaving it asthetically displeasing.
Detect Resizing Of FlexGrid Columns
A simple(?) question:
I am allowing users to resize the columns of a Microsoft FlexGrid control. I would like to change the width of the control in response to the user's change in column width (so that a scroll bar will not be necessary as long as the user doesn't go nuts with the column width).
How do you detect the completion of a columnResize? The MSDN literature seems to allude to using the MOUSEUP event to do this, but it doesn't work. MOUSEUP is not even fired when you are adjusting the column size.
Thanks...
Microsoft Project:: Automatically Changing Width Of Columns
I need to automatically (i.e., via VB) change the width of columns in a microsoft office speadsheet (the sheet area of the Gantt chart
where task information is entered). I've tried several times to record the manual act of doing this using the "macro recorder" -- BUT the
recorder doesn't record this action. Does anyone know how to programmatically adjust the width of the columns in the sheet?
thank you, heather
FlexGrid Columns Will Not Resize With Grid Or Form
HI,
I would like to know if the columns in a FlexGrid should follow the Grid as its sized up or down?
I can resize both the form and the FlexGrid but the columns never change their widths. It appears that I can get the height to change which may have more to do with a dynamically reduced font size as the form/FlexGrid shrinks.
The FlexGrid is dynamically created in a Form_Activate subroutine.
Please advise.
Thanks
Getting Strange Error After Resizing Columns In DataGrid
I have a datagrid that is bound to a recordset. When a user resizes the columns, I am saving the values of the width so they can be reapplied when the grid is refreshed.
Then, when a combo box value changes, I set those variables(width) to 0 and manually set the width of the grid. So this way, the columns will stay the size the user intends.
However, I am now getting a strange error. After I resize the columns, everything works great. When I change the combo box value, and then I try to open the recordset, I get
"error 3265: The item cannot be found in the collection corresponding to the requested name or ordinal". This error occurs when I try to open the recordset."
Very odd. It only happens AFTER I resize the grid, then try to open the recordset again. I'm using the same connection for the whole project and all recordsets, so I don't see why the connection would be "bad" all of a sudden.
I've even taken the query out of the code, but that runs fine in SQLServer, so it's not the actual SQL.
The recordset is closed when I'm trying to open it, so that's not a problem. Here is some code:
Column Resizing Setting Variables:
Private Sub dbgResp_ColResize(ByVal ColIndex As Integer, Cancel As Integer)
If ColIndex = 2 Then wid2 = dbgResp.Columns(ColIndex).Width
If ColIndex = 3 Then wid3 = dbgResp.Columns(ColIndex).Width
If ColIndex = 4 Then wid4 = dbgResp.Columns(ColIndex).Width
If ColIndex = 5 Then wid5 = dbgResp.Columns(ColIndex).Width
If ColIndex = 6 Then wid6 = dbgResp.Columns(ColIndex).Width
If ColIndex = 7 Then wid7 = dbgResp.Columns(ColIndex).Width
If ColIndex = 8 Then wid8 = dbgResp.Columns(ColIndex).Width
End Sub
Here is the code for when the combo box values change:
If cmbEntity.Text = "Clinic" Then
If wid2 = 0 Then dbgResp.Columns(2).Width = 5000 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 3000 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
If wid6 = 0 Then dbgResp.Columns(6).Width = 1000 Else dbgResp.Columns(6).Width = wid6
ElseIf cmbEntity.Text = "Site" Then
If wid2 = 0 Then dbgResp.Columns(2).Width = 3600 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 2600 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
'If wid6 = 0 Then dbgResp.Columns(6).width = 1000 Else dbgResp.Columns(6).width = wid6
ElseIf cmbEntity.Text = "Physician" Then
If wid2 = 0 Then dbgResp.Columns(2).Width = 1300 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 1300 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 3500 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
If wid6 = 0 Then dbgResp.Columns(6).Width = 1000 Else dbgResp.Columns(6).Width = wid6
If wid7 = 0 Then dbgResp.Columns(7).Width = 1000 Else dbgResp.Columns(7).Width = wid7
ElseIf cmbEntity.Text = "Site Staff" Then
Me.dbgResp.Columns(0).Visible = False
Me.dbgResp.Columns(1).Visible = False
If wid2 = 0 Then dbgResp.Columns(2).Width = 1300 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 1300 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 3000 Else dbgResp.Columns(5).Width = wid5
If wid6 = 0 Then dbgResp.Columns(6).Width = 2500 Else dbgResp.Columns(6).Width = wid6
If wid7 = 0 Then dbgResp.Columns(7).Width = 1500 Else dbgResp.Columns(7).Width = wid7
If wid8 = 0 Then dbgResp.Columns(8).Width = 1500 Else dbgResp.Columns(8).Width = wid8
Else
If wid2 = 0 Then dbgResp.Columns(2).Width = 2500 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 2800 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
End If
Any help would be great.
Thanks,
Drew
Resizing MSFlexGrid Control ... Not The Rows/columns
Why not resize the Grid as the containing Form is resized, i.e.
VB Code:
Private Sub Form_Resize() MSFlexGrid1.Move 0, 0, ScaleWidth, ScaleHeightEnd Sub
If the control is on the form with other controls, then just make it stretch with the Form, i.e.
VB Code:
Private tFormWidth As Single, tFormHeight As SinglePrivate tGridWidth As Single, tGridHeight As Single Private Sub Form_Load() tFormWidth = ScaleWidth tFormHeight = ScaleHeight tGridWidth = MSFlexGrid1.Width tGridHeight = MSFlexGrid1.HeightEnd Sub Private Sub Form_Resize() ' Trap error caused if Width/Height are invalid On Error Resume Next MSFlexGrid1.Width = tGridWidth + (ScaleWidth - tFormWidth) MSFlexGrid1.Height = tGridHeight + (ScaleHeight - tFormHeight)End Sub
MSHFlexrid Autosize Question/problem - Extra Columns After Sizing Columns To Autofit
I'm trying to use the MSHFlexGrid control, and it's almost a great thing, but not quite.
I wrote a VB app ( I'm a newbie, and my background is midrange program coding specifically RPG on an AS/400 so please keep that in mind. Event-driven programming and VB are new to me.) that will allow users to "drive" the application and select how they want to see the hierarchy. I let them choose from the pertinent fields and they are popped into a listbox control. The order in which they appear in the listbox control determines the hierarchy, and the underlying code writes the SHAPE, APPEND statements, etc...
So far, great... The problem I have is that since I have no way of knowing what hierarchy the user will select when they run the app, I have no way to know which columns will appear in the grid, or in what order, so there is no way to pre-size the column widths.
I found an autosize routine here posted by FlyGuy, so I put that code behind a button on the form called "AutoFit". When I run the code, it resizes the columns beautifully, but the column headings disappear from the sections over the "children" "grandchildren" "greatgrandchildren" , etc... columns.
Then if I do a collapse/expand, I find that the MSHFlexGrid control has a bunch of empty columns now between the original parent and child columns. The number of columns which appear are equal to the total number of child, grandchild, greatgrandchild, etc... columns fully expanded outward, so in the example shape statement below, I wind up with 16 empty columns on the control. Every subsequent autosize leaves the control with more blank columns. If I scroll far enough to the right, I find the children with their column headers.
The question I have is what is causing this ( the empty columns and the disappearing headings ) to happen, and can I do anything to stop it? I'm not sure it's usable for the end users if this continues to happen. Should I ( or can I ) dynamically set the column widths on the control at run time? Should I load the control by trying to iterate through all the recordsets and maybe do some sort of writing to the control directly? Is there a way to stop the control from showing the repeating columns in the children ( like maybe especially if I write directly to the control )? Can I ( if I write to the control ) format the columns so that numbers are right justified?
I'm using VB6 under Windows Xp Service Pack 2, and service pack 6 for Visual Studio 6 has been applied.
Here is how I was doing it: ( Warning: ugly code alert ):
Dim cnmx As ADODB.Connection
Dim rsMX As ADODB.Recordset
Set cnmx = New ADODB.Connection
Set rsMX = New ADODB.Recordset
With cnmx
.CommandTimeout = 0
.ConnectionTimeout = 0
.Provider = "MSDataShape"
.Open "dsn=<the dsn>;User ID=<the account>;Password=<the password>"
End With
rsMX.Open SQLShapeStatement, cnmx, adOpenStatic, adLockReadOnly, adCmdText
On Error Resume Next
If Err Then MsgBox Error
Set Form3.MSHFlexGrid1.DataSource = rsMX
Form3.MSHFlexGrid1.CollapseAll
rsMX.Close
cnmx.Close
Set rsMX = Nothing
Set cnmx = Nothing
Load Form3
Form3.Show
The value of the SQLShapestatement is:
SHAPE {SELECT USAGECOSTCENTER as Dept, cast(round(SUM(COST), 2) AS decimal(9, 2)) as DeptCst From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' GROUP BY USAGECOSTCENTER ORDER BY DeptCst DESC} AS Level1
APPEND ((SHAPE {SELECT USAGECOSTCENTER as Dept, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) as Equip_Num, cast(round(SUM(COST), 2) AS decimal(9, 2)) as Equip_NumCst From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' GROUP BY USAGECOSTCENTER, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) ORDER BY Equip_NumCst DESC} AS Level2
APPEND ((SHAPE {SELECT USAGECOSTCENTER as Dept, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) as Equip_Num,ITEMNUM as Part_Num, cast(round(SUM(Quantity), 2) AS decimal(9, 2)) as Part_NumQty, cast(round(SUM(COST), 2) AS decimal(9, 2)) as Part_NumCst From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' GROUP BY USAGECOSTCENTER, coalesce(left(
EQNUM,6),(right(USAGECOSTCENTER,4) + '99')),ITEMNUM ORDER BY Part_NumCst DESC} AS Level3
Append ({Select USAGECOSTCENTER as Dept, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) as Line_Num, ITEMNUM as Part_Num, description as Prt_Desc, cast(round(QUANTITY, 2) AS decimal(9, 2)) as Qty, cast(round(COST, 2) AS decimal(9, 2)) as Cst, issuedate as Iss_Dte, Name as Emp_Nme From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' ORDER BY Cst DESC, Emp_Nme, Iss_Dte} as Level4
RELATE 'Dept' to 'Dept','Equip_Num' to 'Equip_Num','Part_Num' to 'Part_Num' )) RELATE 'Dept' to 'Dept','Equip_Num' to 'Equip_Num' ))
RELATE 'Dept' to 'Dept' )
Any suggestions welcome.
Resize Columns Inside A MSFlexGrid, Wrong Scale
CODE:
Private Sub UserForm_Initialize()
Me.msflxgrdMyGrid.FormatString = "<Column 1/<Column 2/<Column 3"
Me.msflxgrdMyGrid.FixedCols = 0
Me.msflxgrdMyGrid.ColWidth(0) = Me.msflxgrdMyGrid.Width / 5
Me.msflxgrdMyGrid.ColWidth(1) = (2 * Me.msflxgrdMyGrid.Width) / 5
Me.msflxgrdMyGrid.ColWidth(2) = (2 * Me.msflxgrdMyGrid.Width) / 5
End Sub
I'm trying to make one column 1/5 the width of the grid, the 2nd as 2/5 the width of the grid and the 3rd as 2/5 the width of the grid.
It looks as if the width of the Grid is being reported as pixels and the ColWidth is expecting twips. I tried setting msflxgrdMyGrid.ScaleMode = vbTwips, but that didn't work. I then tried using the Me.ScaleX(Me.msflxgrdMyGrid.Width , vbPixels, vbTwips) but that didn't work either. I'm really at a loss here if anyone would be kinda enough to help!
TIA!
Chris
Sorting Array With 5 Columns By Any Column Or Columns
Hi all!
I have an array with 5 columns:
- city
- first name
- last name
- birth date
- children quantity
How can I sort this array by any column, for example by 4?
And how can I sort it by few columns, for example:
sort by 5 then sort by 1 then sort by 3?
Delete Emtpy Columns, Deleting All Columns
I've tried almost everything I can think of at this point.
I have a large report generated, imported to Excel.
The beginning of the code (not shown), breaks all merged cells, deletes blank rows, etc.
Now, I'm starting at the far right of the report and want to move column by column to the left deleting empty rows to bring the report together.
Excel 2003 SP2, VBA 6.3
Current code (not working correctly) reads:
Rows("1:1").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "END"
Term = "END"
Range("BL1").Select
While Not (ActiveCell = Term)
ActiveCell.EntireColumn.Select
delcol = False
If Value = "" Then
delcol = True
End If
If delcol = True Then
ActiveCell.EntireColumn.Delete
End If
ActiveCell.Offset(0, -1).Select
Wend
Starts by clearing all contents of row 1, places "END" in A1 so the loop knows when to close. Loop begins in BL1 and moves left until it encounters "END" (in A1) and stops.
Any suggestions or assistance would help maintain my sanity at this point!!!
Thanks in advance.
Dave
Columns(n).Autofit Error Past 257 Columns
When I run my code I get an "Application defined or object defined error" "run time error '1004'"
I thought I saw another thread with the same problem but couldnt find it.
Code:
Private Sub WriteExcelFile()
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
' Create the appropriate instances of Excel and create a new sheet
Set xlApp = New Excel.Application
Set xlWorkBook = xlApp.Workbooks.Add
Set xlWorkSheet = xlWorkBook.Worksheets.Add
' Make the application visible - just toggle the setting
xlApp.Visible = True
Dim n As Integer
For n = 1 To UBound(arrRecords)
'Size columns to data
xlWorkSheet.Columns(n).AutoFit ' <----- This is giving me the error
' Enter a value into cells
xlWorkSheet.Cells(n + 1, 1).Value = Format(arrRecords(n).string1, "#0")
xlWorkSheet.Cells(n + 1, 2).Value = arrRecords(n).string2
xlWorkSheet.Cells(n + 1, 3).Value = Format(arrRecords(n).string3, "#0")
xlWorkSheet.Cells(n + 1, 4).Value = arrRecords(n).string4
xlWorkSheet.Cells(n + 1, 5).Value = arrRecords(n).string5
If arrRecords(n).string6 = 0 Then
arrRecords(n).string6 = 0
Else
xlWorkSheet.Cells(n + 1, 6).Value = Format(arrRecords(n).string6, "$###,##0.00")
End If
If arrRecords(n).string7 = 0 Then
arrRecords(n).string7 = 0
Else
xlWorkSheet.Cells(n + 1, 7).Value = Format(arrRecords(n).string7, "$-###,##0.00")
End If
xlWorkSheet.Cells(n + 1, 8).Value = arrRecords(n).string8
xlWorkSheet.Cells(n + 1, 9).Value = arrRecords(n).string9
xlWorkSheet.Cells(n + 1, 10).Value = arrRecords(n).string10
xlWorkSheet.Cells(n + 1, 11).Value = arrRecords(n).string11
xlWorkSheet.Cells(n + 1, 12).Value = arrRecords(n).string12
xlWorkSheet.Cells(n + 1, 13).Value = arrRecords(n).string13
xlWorkSheet.Cells(n + 1, 14).Value = arrRecords(n).string14
xlWorkSheet.Cells(n + 1, 15).Value = arrRecords(n).string15
xlWorkSheet.Cells(n + 1, 16).Value = arrRecords(n).string16
Next
' Save the spreadsheet
xlWorkSheet.SaveAs "C: est.xls"
' Quit Excel
xlApp.Quit
' Clean up objects
Set xlApp = Nothing
Set xlWorkBook = Nothing
Set xlWorkSheet = Nothing
End Sub
Thanks
Edited by - epatterson78 on 5/25/2003 1:03:58 PM
ListView Columns
How do i add columns to a ListView and also how do i insert information into a listview box? For my listview i require 3 columns: 'Artist', 'Track' and 'CD'.
I have tried adding columns using the properties dialog, but they don't appear when i run the form.
Any help is much appreciated!
James
Listview Columns
if I do lvwListView.listitems.additem ,, "test"
it adds an item in the first column of the listview
how do i add data in the second column of a listview
ListView Columns
I have four columns in a list view, each taking up 25% of the available space. When the form resizes, I am successfully resizing the ListView, but how do I resize each of the columns back to 25% of the new size.
I have tried ListView1.ColumnHeaders.Items(0).Width, but that results in a Out of Bounds Error. I have also tried with Items(1) with the same result.
Any idaes
Listview Columns
thought i would have a go using a listview in report mode.
i must be missing something and see what.
when i insert a column and give it a caption it will insert it but then i have 2 columns.
i wanted 3 columns altogether but it shows 4, always 1 more.
what am i missing ?
thanks
thingimijig.
ListView Columns
If I have 2 columns in a ListView (set to Report), how can I add data to them? I have tried for ages, and I cant figure it out.
Columns To A ListView
Is it possible to add Columns to a ListView manually or does it have to be done at runtime?
Two Columns In Listview
sorry, this may be a silly question but its very frustrating,
all i need is for my listview to display two columns of data, taken from a query currently i can achieve one column but i need to add another with "LastName" cheers, here is my code so far
Code:
Set cn = New ADODB.Connection 'we've declared it as a ADODB connection lets set it.
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= c:vdmcertymate VBdatadata.mdb" 'this is the connection string explained in the notes section.
cn.Open
Set rs = New ADODB.Recordset 'as we did with the connection
rs.Open "qryEmployees", cn, adOpenKeyset, adLockPessimistic, adCmdTable 'opening the recordset explained in the notes
'Code to populate the listView
While Not rs.EOF
lstvEmployees.ListItems.Add , , rs.Fields("FirstName").Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
Me.MousePointer = 0 'Resets Mouse Pointer
oh. and how do i get the listview to add a verticle scrollbar?
Listview Columns
this is a quick question really can u parse a site out into a listview with columns for different info from the site?
its a bit tricky to explain and show you as i want to connect to a site in inet grab the source parse out some hardware information,how many on the site, and how many on order and the price into one listview nicely 'ordered with column headers..
i can connect and parse the hardware info into the listview fine but i was wondering on how to do the other parts but because u need an account on the site i cant show u it however here is some of the info from the source (the parts ive gotten out and im needing to parse out..
HTML Code:
>10/100MBPs NIC</a></td><td align="right">4.96 £</td><td align="right"><div class="g">4</div></td><td align="right"><div class="b">2<
theres say part of the info from the source ive gotten the 10/100 "part" fine but i need to get the "4.96, class="g">4< amount and class="b">2< amount (which change obviously...
is this possible to parse into a listview with columns to save me having to go to the site each time and then get those parts of the info which really defeats the purpose of the program? or do i need to use a different control other than listview?
any help or tips would be great
Listview With Different Columns?
In Listview I want to create 5 columns each having column header as "S.No", "From", "Subject", "Date", "Time"
I created Column headers in design time but they are not getting displayed? Also I want that S.No column to be having Checkboxes. How to do that? Thanks.
Listview Columns
I can only select the index column out of my data when in a listview. Code and input follows: Also I cannot input files other than the one I used to test with, of the same format?! (Not the one attached)
Option Explicit
Private Sub Form_Load()
Dim K As Integer
Dim itmX As ListItem
Dim clmX As ColumnHeader
K = 1
Set clmX = ListView1.ColumnHeaders.Add(, , "Column 1", ListView1.Width / 5)
ListView1.BorderStyle = ccFixedSingle
ListView1.View = lvwReport
ListView1.ListItems.Clear
Dim FF As Integer
Dim strLine As String
FF = FreeFile
Open "C:sheet.csv" For Input As #FF
Do While Not EOF(FF)
Line Input #FF, strLine
AddListView strLine
Loop
Close #FF
End Sub
Private Sub AddListView(S As String)
Dim Ar() As String
Dim i As Integer
Ar = Split(S, ",")
If UBound(Ar) > ListView1.ColumnHeaders.Count Then
For i = ListView1.ColumnHeaders.Count To UBound(Ar)
Dim clmX As ColumnHeader
Set clmX = ListView1.ColumnHeaders.Add(, , "Column " & i + 9, ListView1.Width / 5)
Next
End If
Dim lv As ListItem
Set lv = ListView1.ListItems.Add(, , Ar(0))
For i = 1 To UBound(Ar)
lv.ListSubItems.Add , , Ar(i)
Next
End Sub
Private Sub SortListView(ByRef List As ListView, ColHeadIndex As Integer)
Dim lcv As Long 'Loop Control Variable
With List
' Make sure the Sorted property is set to true
.Sorted = True
' Sort according to the colum that was clicked (off by one)
.SortKey = ColHeadIndex - 1
' Does the column already have an icon?
If .ColumnHeaders(ColHeadIndex).Icon = 0 Then
'No, So we will assume this column is not sorted
' Set to Ascending order
.SortOrder = lvwAscending
' Set the sort order to descending
.SortOrder = lvwDescending
Else
' Otherwise sort into ascending order
' Set to Ascending order
.SortOrder = lvwAscending
End If
' Refresh the display of the ListView Control
.Refresh
End With
End Sub
Listview Columns
when using a listview in report mode, do you always have to have a blank list at the end.
when i add columns through its properties there is always another blank one, and if i try and size it to fit the size i want it either still shows a bit of the blank one or i get rid of it and a scrollbar appears.
any ideas!
thanks.
thingimijig.
ListView Columns
Sups,
I got a listview with two columns on it.
I forgot how to add item to each column.
How can I do that?
tnx.
ListView And Columns
How can I set the column width to be that of the text? I tried:
VB Code:
lstOutput.ColumnHeaders(1).Width = TextWidth(strText)
But that didn't work...
Any ideas?
ListView Columns
I have 5 columns in the ListView, all were added via code at runtime. Now, for example, I want to remove column with index 2, problem is, the data from the last column disappears and all the data gets shifted so column with index 3 will now have what column with index 2 had before removing. Is there an easy way to remove column and all the data in it (like Access 2000 does) or do I have to go item by item moving subitems from each column to previous one making 2 last columns identical in data but not column header text, then it should work, because last column will be removed anyway. Here's when another problem comes up, if I add a new column, the data from last column will become visible again, so I really didn't remove column completely, just the column header and made data in the last column invisible. Maybe when I'm adding columns, I need to specify a key or index or what not to remove it completely? I just want to remove the whole column (header and data in it) completely, and shift all the columns to the left; and when I add a new column, I want it to be "blank", meaning no data in it. Of course, it all can be done via long code. I have to set each item's subitem of the new added column to "", etc. but there should be an easier way!
Thanks
|