Listview Columnheader Re-position
I searched the forums and could not find an answer to this question.
I have a form with 2 listview objects. Both have the same column headers. What I want to do is, when the user re-arranges the columns in listview1, I want to programatically re-arrange the columns in listview2 to match. I can't seem to get this to work. I tried the mouseup, columnclick, & lostfocus events but they do not seem to fire on repositioning of the columns.
Does anyone know how this can be done?
Thanks!!!!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
ListView ColumnHeader Size
Hi, I'm having a bad flicker problem with resizing a ListView in Report Mode.
I have two columns: one of names, and one of numbers. The one of names changes size as the ListView changes size, and the one of numbers stays the same size and stays against the right side of the ListView. Unfortunately, ListViews seem to only work in Twip mode, and that causes flickering on certain sizes (when it should round up [0.5]). Is there any way to make the ColumnHeaders go to Pixels size, or at least to tell it to round up instead of down?
Listview Columnheader Icons
How do you insert the Icons into the column header in VB 5?
Also how do you program the headers to sort the columns if it has been clicked.
Thanks
ListView ColumnHeader Colors
I'm working on a form using Listview, and have managed to figure out quite a bit so far in getting it functioning. Now I would like to add to the look of the form. I cannot find any property that will change color of the column header. Could you assist me in how to do this, or an on-line manual that would show this type of information. Thanks.
ListView - ColumnHeader - Bold
Hi,
I want to make 1 columnheader bold and leave the others as they are.
If a user clicks on a columnheader, it should be bold and alll the others regular font.
Thanks,
ListView - ColumnHeader's Width
Did you see when you double-click over the "border" of the columnheader that its width changes to fit all the info in it? Is there any way to programmatically do this?
ListView - ColumnHeader Tooltips
Hello,
In looking how to accomplish the task of displaying a tooltip when the user moves the mouse over a given columnheader of a listview, I stumbled across this example:
http://www.codeguru.com/cpp/controls...cle.php/c4171/
However, I just want to display a standard tooltip, not a balloon. Do you know what I would need to change in this code to accomplish that?
And also is it possible to accomplish this without all the subclassing?
ListView ColumnHeader Cursor
Hi Everyone,
I am currently using the code provided by Aaron Young to disable ListView column resizing however, I cannot figure out how to stop the cursor from changing while over these non resizable columns. I think I should use the WM_SETCURSOR API but I am unsure how to do it. Does anyone know how to do this? I would appreciate any help. Thank you.
Resizing The Columnheader In A Listview
Hi All,
I am trying to change the size of a listviews columnheader based on the length of a string.
I am sure there is a better way of doing, it but I have not found it.
Here is what I have so far, but it does not seem to be the exact length as my string.
Any ideas?
Thanks.
Set Itemx = ListView1.ListItems.Add(, , "This is the Test Text ")
If Len(Itemx.Text) * 100 > ListView1.ColumnHeaders(1).Width Then
ListView1.ColumnHeaders(1).Width = Len(Itemx.Text) * 100
End If
ListView Columnheader AutoSize
I need the column in a listview to adjust its width to fit its contents... How exactly would i achieve this?
Twisted|Soul
Transcending even the highest forms of digital spirituality.
Listview ColumnHeader Property
Why don't I get the property 'Position' in ColumnHeader object
I'am using MSCOMCTL.OCX and Vb6 (sp6)
'*****
Private Sub Form_Load()
Dim colx As ColumnHeader
Dim colPos As ColumnHeader
'Let the user reorder the columns
ListView1.AllowColumnReorder = True
'Set view to report
ListView1.View = lvwReport
'Add some columns
Set colx = ListView1.ColumnHeaders.Add(, , "Col1")
Set colx = ListView1.ColumnHeaders.Add(, , "Col2")
Set colx = ListView1.ColumnHeaders.Add(, , "Col3")
Set colx = ListView1.ColumnHeaders.Add(, , "Col4")
Set colx = ListView1.ColumnHeaders.Add(, , "Col5")
Set colx = ListView1.ColumnHeaders.Add(, , "Col6")
'Loop though each ColumnHeader object and set the
'position of it dependent on what the user did
'the last time
For Each colx In ListView1.ColumnHeaders
colx.Position = GetSetting(App.Title, "Settings", "Col" & colx.Index, colx.Index)
colx.Width = GetSetting(App.Title, "Settings", "ColWidth" & colx.Index, colx.Width)
Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim colx As ColumnHeader
'Save the Position of each of the ColumnHeader
'Objects so we can load them the next time
'the user starts the program
For Each colx In ListView1.ColumnHeaders
SaveSetting App.Title, "Settings", "Col" & colx.Index, _
ListView1.ColumnHeaders(colx.Index).Position
SaveSetting App.Title, "Settings", "ColWidth" & colx.Index, _
ListView1.ColumnHeaders(colx.Index).Width
Next
End Sub
'**''
aeg
Listview - Lock Columnheader
Hi, how can I lock the column header on top of my listview? I have set it to lvwReport. I have some standard headers wich contain not much data. The headers are big enough to contain all the data. How to lock them?
Sand Hawk
Earth is 98% full. Please delete anybody you can.
Listview Columnheader Icons
How do you add icons to the columnheaders of common control 5 listviews? I using common control 5 for xp styles.
ListView: ColumnHeader With Icon Will Not Right-align
I have a ListView with four ColumnHeaders.
The first three ColumnHeaders have icons to indicate the sorted column and the direction of the sort.
The last two ColumnHeaders are supposed to be right-aligned.
The third ColumnHeader is left-aligned even though I set the alignment to be right-aligned.
The fourth ColumnHeader is the only one without an icon and it is right-aligned like it should be.
It looks like if an icon is specified for a ColumnHeader it automatically makes it left-aligned. Is there anyway to have an icon and be right-aligned?
Here is my code for creating the columnheaders:
Code:
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "DATE & TIME", 2500, lvwColumnLeft, "SORT_ASC")
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "TYPE", 1400, lvwColumnLeft, "BLANK")
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "AMOUNT", 2000, lvwColumnRight, "BLANK")
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "BALANCE", 2000, lvwColumnRight)
Any thoughts?
Thanks.
Listview Columnheader Icon Question
I am presenting data in a listview and am having a problem with columnheader icons. I am displaying an up or down arrow icon to indicate the sort order and I want to remove the icon from the header if the user selects a different column. The only method that I have come up with is to clear and readd all columns to the collection but this is slow and clumsy looking. Is there another option? Thanks in advance for all help.
Print Listview Listitems And Columnheader
How to set the A4 paper to print the listview listitems and listview column header as lanscape or potrait?By default it print as potrait. So How to set the paper to print as lanscape if the columnheader reach the A4 limit margin size?
Code:
'Print Column Header
Dim head As ColumnHeader
Dim colColumnIndexes As Collection
Dim Idx As Long
Dim iTab As Long
Set colColumnIndexes = New Collection
iTab = 5
Printer.FontUnderline = True
'Print the column headers and load the collection of
'column indexes that will be used when printing the ListView data.
For Idx = 0 To printtext.List2.ListCount - 1
For Each head In Form5.ListView2.ColumnHeaders
If printtext.List2.List(Idx) = head.Text Then
Printer.Print Tab(iTab); printtext.List2.List(Idx);
iTab = iTab + 30
colColumnIndexes.Add head.SubItemIndex
End If
Next
Next
Printer.Print
Printer.Print vbCrLf
'Print ListItem
Dim item As ListItem
Dim strItem As String
For Each item In Form5.ListView2.ListItems
iTab = 5
For Idx = 1 To colColumnIndexes.Count
Printer.FontUnderline = False
If colColumnIndexes(Idx) = 0 Then 'this is not a subitem, so print the listitem data
strItem = item.Text
Else
strItem = item.ListSubItems(colColumnIndexes(Idx)).Text
End If
Printer.Print Tab(iTab); strItem;
iTab = iTab + 25
Next
Printer.Print
Next
Printer.EndDoc
Right Click ColumnHeader In ListView To PopupMenu
What would be the easiest way to make a popupmenu on a right click of the mouse, on the column header section?
The mouseup event on a listview doesn't happen if you click the header.
The column_Click event doesn't have a button variable.
Picture Below
ListView ColumnHeader Icons (with ImageList)
Hey,
Haven't done this before so I thought I would give it a shot. I am able to sort the ListView columns by clicking on the ColumnHeader without a problem. But now I would like to add an icon to the ColumnHeader from an ImageList to show the sorting order.
This is what I have:
1) ListView = lvwPrefixes
2) Image List = ImageListPrefixesListView
3) Two icons, one with a Key called Ascending for image index 0 and another with a Key called Descending for the image index 1
The icon isnt displaying because I have no idea how to reference the image list in the code. Searched and found nothing useful so far.
Please advise, thanks in advance.
The current code is:
VB Code:
Private Sub lvwPrefixes_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) With Me.lvwPrefixes If .SortOrder = lvwAscending Then .SortOrder = lvwDescending .ColumnHeaders.Icons = "Descending" Else .SortOrder = lvwAscending .ColumnHeaders.Icons = "Ascending" End If .SortKey = ColumnHeader.Index - 1 End WithEnd Sub
I also have
VB Code:
Me.lvwPrefixes.Sorted = True
in the Form_Load event of the form
Sorting Off A ListView ColumnHeader Click
Before I go about coding something that's already built in I just want to make sure:
I need users to be able to sort the ListView by clicking the different ColumnHeaders (ala Outlook Inbox.)
I'm ready to write the code from scratch, but I just want to make sure that I'm not writing code for something that I could do with an API.
Transparent Icon In ListView ColumnHeader?
ok i added some icons to the columnheaders on a listview, and they are gif files, with a transparent background, which worked first time. i havent changed any properties i dont think, all ive done is resize the images in paint shop pro, made sure that the background transparancy was still set for the file, but now they're not transparent???/
is there something im missing?
a property setting ???/?
ListView: ColumnHeader With Icon Will Not Right-align
I have a ListView with four ColumnHeaders.
The first three ColumnHeaders have icons to indicate the sorted column and the direction of the sort.
The last two ColumnHeaders are supposed to be right-aligned.
The third ColumnHeader is left-aligned even though I set the alignment to be right-aligned.
The fourth ColumnHeader is the only one without an icon and it is right-aligned like it should be.
It looks like if an icon is specified for a ColumnHeader it automatically makes it left-aligned. Is there anyway to have an icon and be right-aligned?
Here is my code for creating the columnheaders:
Code:Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "DATE & TIME", 2500, lvwColumnLeft, "SORT_ASC")
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "TYPE", 1400, lvwColumnLeft, "BLANK")
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "AMOUNT", 2000, lvwColumnRight, "BLANK")
Set ObjLstColHeader = lstTransactions.ColumnHeaders.Add(, , "BALANCE", 2000, lvwColumnRight)
Any thoughts?
Thanks.
Edited by - george957_1 on 3/12/2004 3:54:19 PM
Listview Columnheader Alignment Problem
I have a listview control which I'm filling with file information (name, path, size, etc.). I am using a sort routine so that I can sort by numeric and date columns as well as string columns. The sort routine just saves the numeric or date text, and then transforms it into a sortable string. Once the sorting is complete, it replaces the sortable strings with the original text. This seems to be a standard way of working around the Listview sorting problem.
The problem I'm running into is that after a sort, (no matter which column is sorted) my numeric column loses its right-alignment and changes to left-aligned. I've tried resetting it to right-aligned after each sort, but it doesn't seem to work. This is the line I'm using to do that (it's the last statement in my "lvwDrive1_ColumnClick" event:
lvwDrive1.ColumnHeaders(3).Alignment = lvwColumnRight
I've tried right-aligning other columns after a sort, and it usually works the first time I do a sort, but if I click the columnheader again to re-sort, the alignment doesn't happen. Does anyone know what I can do to fix this?
Thanks,
Kris
Listview Columnheader And Item Text Alignment
Hi, is it possible to set a different alignment for both the Listview columnheader and item text?
I'd like to center the text of all columnheaders and align the item text to the left or right.
Is it also possible to change the height of the columnheader?
The columnheader looks rather thin when the app is maximized.
ListView, Detect Scroll? Columnheader Height?
Are there any easy/smart ways to do the following:
Check the height of the columnheaders in a ListView?
Check if there's a scroll in my ListView (due to low resolutions for eg.)
Code is heavily appreciated!
Thanks in advance!
When Press Parentnode In Treeview, Listview Columnheader Shows, When I Press Root Nod
Hai Every one, Quote:The below typed content seems to be large but the matter may be simple for you. kindly view and reply. The details in listview are shown correctly only the Columnheader is problem. My problem is, when I click the Parent node the Columnheader of the listview changes as per the coding correctly, but when I click the plus sign of the tree and click any one node, the columnheader is not changed. I write the code and tried in many ways up to my knowledge. but I can't get what I need. So i am using temporarily the below given code.
It diplays columnheader correctly when I click parent node, but i need to display the columnheader when I click a root node. by seeing the code you can get what I am trying to do.
The below code is I tried and trying, not yet success. here I am setting the column header according to the node clicked by lhe user.
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
On Error Resume Next
ListView1.ListItems.Clear
Call lvf
If TreeView1.SelectedItem.Text = "Product Name" Then
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add 1, , "Part Number"
ListView1.ColumnHeaders.Add 2, , "Description"
ListView1.ColumnHeaders.Add 5, , "Unit Cost"
End If
If TreeView1.SelectedItem.Text = "Part Number" Then
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add 1, , "Description"
ListView1.ColumnHeaders.Add 2, , "Product"
ListView1.ColumnHeaders.Add 5, , "Unit Cost"
End If
If TreeView1.SelectedItem.Text = "Description" Then
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add 1, , "Part Number"
ListView1.ColumnHeaders.Add 2, , "Product"
ListView1.ColumnHeaders.Add 5, , "Unit Cost"
End If
End Sub
the below code is just for your information not the full code, i used this function to call it in the treeview node_click event, this is to list details in the listview for the item selected in the Treeview.
Private Sub lvf()
Dim lit As ListItem
Dim lis As ListItem
rsl.Open "select SC030100.SC03064 from SC010100,SC030100 where SC010100.SC01001=SC030100.SC03001 AND SC010100.SC01037='" & TreeView1.SelectedItem.Text & "' order by SC010100.SC01001", cnn, adOpenStatic, adLockReadOnly
While Not rsl.EOF
Set lit = ListView1.ListItems.Add(, "a" & i, rsl.Fields("SC01001"))
lit.ListSubItems.Add , "l" & j, rsl.Fields("SC01002")
rsl.MoveNext
i = i + 1
j = j + 1
Wend
rsl.Close
rsil.Open "select SC030100.SC03064 from SC010100,SC030100 where SC010100.SC01001=SC030100.SC03001 AND SC010100.SC01001='" & TreeView1.SelectedItem.Text & "'", cnn, adOpenStatic, adLockReadOnly, adCmdText
While Not rsil.EOF
Set lit = ListView1.ListItems.Add(, "z" & j, rsil.Fields("SC01002"))
lit.ListSubItems.Add , "x" & j, rsil.Fields("SC01037")
rsil.MoveNext
j = j + 1
Wend
rsil.Close
rsdl.Open "select SC030100.SC03064 from SC010100,SC030100 where SC010100.SC01001=SC030100.SC03001 and SC010100.SC01002='" & TreeView1.SelectedItem.Text & "'", cnn, adOpenStatic, adLockReadOnly, adCmdText
While Not rsdl.EOF
Set lit = ListView1.ListItems.Add(, "f" & i, rsdl.Fields("SC01001"))
lit.ListSubItems.Add , "g" & i, rsdl.Fields("SC01037")
rsdl.MoveNext
i = i + 1
Wend
rsdl.Close
End Sub
the below is the code which I written to add the parent and root nodes, the text "Parent Name","Part Number" are not the real Field Names, just for users identification I given like this.
Private Sub Form_Activate()
Set ns = TreeView1.Nodes.Add(, , "N", "Product Name", 1)
Set ns = TreeView1.Nodes.Add(, , "F", "Part Number", 1)
Set ns = TreeView1.Nodes.Add(, , "S", "Description", 1)
While Not rs.EOF
Set ns = TreeView1.Nodes.Add("N", tvwChild, "a" & i, rs.Fields("SC01037"))
rs.MoveNext
i = i + 1
Wend
While Not rsi.EOF
Set ns = TreeView1.Nodes.Add("F", tvwChild, "w" & j, rsi.Fields("SC01001"))
rsi.MoveNext
j = j + 1
Wend
While Not rsd.EOF
Set ns = TreeView1.Nodes.Add("S", tvwChild, "m" & i, rsd.Fields("SC01002"))
rsd.MoveNext
i = i + 1
Wend
End Sub
If its possible correct the code or give me your suggestion. Kindly reply me.
Thank you,
CHOCk.
itchocks@rediffmail.com
<HTML>
<B><font color="#008000">HAVE A NICE DAY !</font></B>
<HTML>
Edited by - chs on 10/9/2002 8:45:42 AM
Listview - How To Re-position The Scroll Bar To The Top
after i've sorted the items within the listview, the scroll bar appears to be in the bottom (showing the last line). how can i position it to be on top (means shows the first line)
your guidance is very much appreciated. thanks
Listview Item Position
Im trying to find the top left hand corner X and Y positions of any item selected in a listview, anybody know ?
thanks.
Get Mouse X Position On A Listview With Scroll
I have made a sort of a calendar with a listview control. Columnheader 1 is a person and columnheader 2-8 is the weekdays.
When i click on the listview i calculate which column is clicked by the columnheader size and the parameter x of the listview mouseup function. My calculation looks like this:
Dim iManStart As Integer, iTirStart As Integer, iOnsStart As Integer, iTorStart As Integer, iFreStart As Integer, iLorStart As Integer, iSonStart As Integer
iManStart = frmMain.lstWrk.ColumnHeaders(1).Width
iTirStart = iManStart + frmMain.lstWrk.ColumnHeaders(2).Width
iOnsStart = iTirStart + frmMain.lstWrk.ColumnHeaders(3).Width
iTorStart = iOnsStart + frmMain.lstWrk.ColumnHeaders(4).Width
iFreStart = iTorStart + frmMain.lstWrk.ColumnHeaders(5).Width
iLorStart = iFreStart + frmMain.lstWrk.ColumnHeaders(6).Width
iSonStart = iLorStart + frmMain.lstWrk.ColumnHeaders(7).Width
Select Case frmMain.siMouseX
Case iManStart To iTirStart
MsgBox "mandag"
Case iTirStart To iOnsStart
MsgBox "tirsdag"
Case iOnsStart To iTorStart
MsgBox "onsdag"
Case iTorStart To iFreStart
MsgBox "torsdag"
Case iFreStart To iLorStart
MsgBox "fredag"
Case iLorStart To iSonStart
MsgBox "lørdag"
Case Is > iSonStart
MsgBox "søndag"
End Select
My problem is, that if i scroll to the right on the listview control, the X returns the value of the visible area of the listview control. Is the something i can do to calculate the right column clicked, or can i do this in another way?
Saving Listview Selected Position
Whats the best way in a listview report style saving the currently selected item (if it has one)
and restore it later (same item selected again after refilling the list) ??
I tried to save its index as integer
and restore it but it didnt select it
Listview1.Listitems.Index(i).selected = true
thanks
VB6 Listview: Vertical Scrollbar Position
Hi,
I'm using a listview with two columns to display items from a file, the listview control adds all my data but each time i "refresh" it the vertical scrollbar automatically adjusts itself to the centre. ie. skipping the first items and showing all the items in the centre by default. How can i rectify this?
Thanks
Detecting The Scroll Position Of A ListView
Hi Team
When users click on my listview a textbox appears where they clicked and allows them to edit the listview subItem. This all works fine.
The problem is that if the listview is scrolled to the right the mousedown event gives coordinates of the click as if the listview has not been scrolled.
So what I need is to detect the scroll position of the listview. Does anyone know how to do this?
FW
Position ListView To Selected Item
Hi,
I have searched through a listview for a particular string and it has found the relevant record , see below code.
My problem is that the list is over 3000 records long and I would like the selected item to appear at the top of the visible listview box,
any ideas
Jeff
Code:
Dim itm As ListItem
With ListView1
Set itm = .FindItem(custsearch_txt.Text, lvwText, , lvwPartial)
If Not itm Is Nothing Then
.ListItems(itm.Index).Selected = True
.SetFocus
ListView1_Click
.Refresh
End If
End With
Set itm = Nothing
Remember Listitems Icon Position In Listview
hello everyone... is there a property i can set the position of the listitems in my listview? you know, just in windows explorer, it can remember the positions of listitems if the view is set to "Icons". hope you guys could help.
How To Position Selected Item To Top Of Listview Control
The codes below allows me to search for a particular item in the listview control by typing a search text. How can I position the selected item to the top of the listview control ?
Thanks in advance.
Private Sub txtSearch_Change()
Dim itmX As ListItem
Dim sSearch As String
Dim iTest As Integer
sSearch = txtSearch.Text
Set itmX = lstvFields.FindItem(sSearch, , , lvwPartial)
Set lstvFields.SelectedItem = itmX
If itmX Is Nothing Then
Exit Sub
Else
itmX.EnsureVisible ' Scroll ListView to show found ListItem.
itmX.Selected = True ' Select the ListItem.
lstvFields.SetFocus ' Return focus to the control to see
' selection.
End If
End Sub
Columnheader In Mshflexgrid
how to get an event in mshflexgrid that a column-header has been clicked..
like listview control while clicking on columnheader of listview,,we can sort on that column i want it same in hierachical flex grid.
DataGrid ColumnHeader
How do I put into codes the header names of the datagrid. (i.e. "Last Name", "First Name"). I know how to do it in mshflexgrid by using .textmatrix property. What property is responble for that in datagrid?
Columnheader Color
Can anyone tell me how to change the color of the columnheader in ListViewCtrl? Can't find any info.
|